the strings are treated as charactor arrays in c and therefore the rules for passing string to functions are very similar to those for passing arrays to funcations.

basic rules are:

1>> the string to be passed must beclared as a formal argument of the funcation when it is defined exampl

 

void display(char item_name[ ])

{

 ................................

 .................................

}

2>>the funcation prototype must show that the argument is a string. for the above funcation definition , the prototype can be written as

                               void display(char str[ ]);

3>>a call to the funcation must have a string array name without subscripts as its actual argument example:

                                   display(name);

where names is a properly declared string array in the calling funcation .

we must note here that , link arrays , strings in c cannot be passed by value to funcations.


Like it on Facebook, Tweet it or share this article on other bookmarking websites.

No comments