The first array prints all right.
test[] =
However, when the array is like in the second example, test[][] ={"...","..."};
I get an incompatible warning.
In the second example with fputs, it prints without a line break and with printf, nothing prints.
#include <stdio.h>
//String to display Test
const char test[] =
"|T|\n\
|E|\n\
|S|\n\
|T|\n\
";
int main(){
//Print test
fputs(test,stdout);
printf("\n");
return 0;
}
Second example.
#include <stdio.h>
#define LINE 4
#define COLN 5
//String to display Test
const char test[LINE][COLN] ={
" |T| ",
" |E| ",
" |S| ",
" |T| "
};
int main(){
// Print test
//printf("%s", test);
fputs(test,stdout);
printf("\n");
return 0;
}
Warnings
_______________________________________________________________________________
field width should have type 'int', but argument has type 'const char (*)[11]'
[-Wformat] printf("%*s",test);
~^ ~~~
_______________________________________________________________________________
incompatible pointer types passing 'const char[11][11]'
to parameter of type 'const char ' [-Wincompatible-pointer-types]
fputs(test,stdout);
^~~~
passing argument to parameter '__s' here
int fputs(const char __s, FILE* __fp);
^