c - Why strings are permitted while arrays are not in this code? -
#include<stdio.h> void function1(){} int main(void) { function1(1,0.45,'b',"i trying"); function1(); return 0; } this compiles nicely. below showing
error: use arr in function1 first....
note using code::blocks ide , saved file .c extension.
#include<stdio.h> void function1(){} int main(void) { function1(1,0.45,'b',"i trying",arr[12]); function1(); return 0; } sorry made mistake calling array. {1,2,3,4} array agree ..but not work. bug or ?
in second case,
function1(1,0.45,'b',"i trying",arr[12]); arr[12] variable, , arr not defined, least being array.
in c, need define variable before using it.
fwiw,
function1(1,0.45,'b',"i trying"); works, because
1intliteral0.45doubleliteral'b'charliteral"i trying"string literal
and none of them variable.
Comments
Post a Comment