Reputation: 13
I am new to C and im trying to work with Global variables i ran this program and all get as output is "Hey there" Which is the first part of the program. The second part doesn't get displayed. Here's the code.
char count[20]="Hey there";
char dig[7]="pooop";
main()
{
puts(count);
return(0);
}
hey()
{
printf(" i %s you", dig);
return(0);
}
Upvotes: 0
Views: 117
Reputation: 143047
You need to call the second function hey()
before you can get its output.
E.g., in main()
{
puts(count);
hey();
return 0;
}
where exactly you put the call to hey()
in main()
is up to you (it needs to be before the return
statement though).
Upvotes: 2
Reputation: 60768
The function hey
isn't called. I can't really explain this further without writing a programming textbook here. So you'll need to find one.
Upvotes: 1
Reputation: 375574
You need to invoke the function hey()
someplace if you want it to run. C programs start with main()
, and whatever main
does is what the program does. Call hey
from main
if you want hey
to run.
Upvotes: 1