#include<stdio.h> int main() { char str[3][10]={ "vipul", "ss", "shreya" }; why won't work:
printf("%s",str[1][0]); if want access str whereas
printf("%s",&str[1][0]); or perfectly
printf("%s",str[1]); can explain ? why first code giving error
prog.c: in function ‘main’: prog.c:9:5: error: format ‘%s’ expects argument of type ‘char *’, argument 2 has type ‘int’ [- werror=format] cc1: warnings being treated errors why argument has type int?
printf("%s",str[1][0]); the problem in line. when %s format specifier, printf() expects pointer null terminated string. whereas str[1][0] char (specifically first s in "ss"), promoted int (default argument promotions). that's error message says.
Comments
Post a Comment