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

  • 1 int literal
  • 0.45 double literal
  • 'b' char literal
  • "i trying" string literal

and none of them variable.


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -