replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Printing from inside a function with SCC?
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Printing from inside a function with SCC?

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
Little-Acorn



Joined: 06 Jul 2008
Posts: 111
Location: San Diego

PostPosted: Tue Nov 27, 2012 5:42 am    Post subject: Printing from inside a function with SCC? Reply with quote

I drew a simple function, intended to print out a single line (with several carriage-returns). But for some reason it doesn't.

First the main program should print out a carriage return followed by "Hello, world! Value =" followed by an integer value, then a couple carriage returns. Then it should print "Function writstat has been entered" with a couple more carriage returns, and then a single integer value.

I expected to get a garbage value (actually a pointer value) back, and I did. No surprise there.

But why it doesn't print out "Function writstat has been entered" with the carriage-returns?

---------------------------------------------

#include "stdio.h"

int writstat()
{
int i;
i=13;
printf("\nFunction writstat has been entered.\n\n");
return(i);
}

main()
{
printf("Hello, world! Value = %d\n\n",writstat);
}

---------------------------------------------------
Back to top
View user's profile Send private message
jalih



Joined: 30 Jul 2012
Posts: 196

PostPosted: Tue Nov 27, 2012 7:03 am    Post subject: Re: Printing from inside a function with SCC? Reply with quote

Little-Acorn wrote:

But why it doesn't print out "Function writstat has been entered" with the carriage-returns?

It's simply because you never call the function writstat in your code, you are missing () after the function name.

There are other errors in your code:

- standard headers should be included as:
Code:
#include<stdio.h>


- main function should return a integer value. Old compiler assumes this and let's your code compile without nagging, but it's still a good habit.
Back to top
View user's profile Send private message
Little-Acorn



Joined: 06 Jul 2008
Posts: 111
Location: San Diego

PostPosted: Tue Nov 27, 2012 7:16 am    Post subject: Re: Printing from inside a function with SCC? Reply with quote

jalih wrote:
Little-Acorn wrote:

But why it doesn't print out "Function writstat has been entered" with the carriage-returns?

It's simply because you never call the function writstat in your code, you are missing () after the function name.

That was it! Thank you!

Quote:
There are other errors in your code:

- standard headers should be included as:
Code:
#include<stdio.h>


- main function should return a integer value. Old compiler assumes this and let's your code compile without nagging, but it's still a good habit.

I have now corrected my code to include these. Thanks for your help!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group