I've tryed to print out some array of strings but faced error: excess elements in char array initializer Please make a hint what's worng with this code?
Step 1 change '' with "" nothing changed, the same error. Step 2 change maschar to *maschar, it helped, thaks.
#include <stdio.h>
#include <stdlib.h>
int main()
{
char maschar[] = {'char', 'mas', 'got'};
int lenchar = sizeof(maschar) / sizeof(*maschar);
for (int i = 0; i< lenchar; i )
printf("%s\n", *(maschar i));
return 0;
CodePudding user response:
Step 1 change '' with "" nothing changed, the same error. Step 2 change maschar to *maschar, it helped, thaks.
char *maschar[] = {"char", "mas", "got"};
int lenchar = sizeof(maschar) / sizeof(*maschar);
for (int i = 0; i< lenchar; i )
printf("%s\n", *(maschar i));