Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Data argument not used by format strings in C [duplicate]

Tags:

c

string

printf

An error is being given on all printf statements stating:

Data Arguement Not Used by Format Strings.

I looked around on the internet and found some related things however I did not fully comprehend the solution and was hoping maybe someone on here could explain further.

void displayPuzzle()
{
int i, j;
char x = 'A';

for (i = 0; i < COLOUMNS; i ++)
{
    printf("%c  ", x); //error here
    x++;
}
printf("\n\n");
for (i = 0; i < ROWS; i ++)
{
    printf("%d\t", i); //error here
    for (j = 0; j < COLOUMNS; j ++)
    {
        printf("%c  ", puzzle[i][j]); //error here
    }
    printf("\n\n");
}

}
like image 345
David Avatar asked Dec 19 '25 16:12

David


1 Answers

Format string specifiers for printf use % to denote the start of a format specifier, not &.

void displayPuzzle()
{
    int i, j;
    char x = 'A';

    for (i = 0; i < COLOUMNS; i ++)
    {
        printf("%c  ", x);
        x++;
    }
    printf("\n\n");
    for (i = 0; i < ROWS; i ++)
    {
        printf("%d\t", i); 
        for (j = 0; j < COLOUMNS; j ++)
        {
            printf("%c  ", puzzle[i][j]); 
        }
        printf("\n\n");
    }

}
like image 122
dbush Avatar answered Dec 22 '25 10:12

dbush



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!