Home > Back-end >  But why textbook can run, the practice can't (small white just learning c language)
But why textbook can run, the practice can't (small white just learning c language)

Time:09-21

[example] 5.1 function no arguments,
The program code is as follows:
# include "stdio.h"
Void printstar ()
{
Printf (" * * * * * * * * \ n ");
}
Void print_message ()
{
Printf (" how do you do \ n ");
}
Void main ()
{
Printstar ();
Print_message ();
Printstar ();
}


The results are as follows:
* * * * * * * * * * *
How do you do
* * * * * * * * * * *

CodePudding user response:



What are you talking about?

CodePudding user response:

reference 1/f, ghost L reply:


What are you talking about?

Textbook code, completely copy down but can't run

CodePudding user response:

The code will be a problem, the problem of the original poster is compiled yet? (because of the main return value type is void, try to int)
Or compile well can't run? (because of the lack of the system (" pause "); ?).

CodePudding user response:

reference 3 building self-confidence boy reply:
code will be a problem, the original poster compile but is the problem? (because of the main return value type is void, try to int)
Or compile well can't run? (because of the lack of the system (" pause "); ?).

I asked the teacher, the teacher said network programming environment does not support the void, thank you

CodePudding user response:

Void main () this kind of writing is not the standard way, suggest or according to the standard int main () this kind of writing

CodePudding user response:

Amended as below so it should be no problem,
# include "stdio.h"
Void printstar ()
{
Printf (" * * * * * * * * \ n ");
}
Void print_message ()
{
Printf (" how do you do \ n ");
}
Int main ()
{
Printstar ();
Print_message ();
Printstar ();
return 0;
}

CodePudding user response:

refer to 6th floor Tryagain2006 response:
modify for this should be no problem,
# include "stdio.h"
Void printstar ()
{
Printf (" * * * * * * * * \ n ");
}
Void print_message ()
{
Printf (" how do you do \ n ");
}
Int main ()
{
Printstar ();
Print_message ();
Printstar ();
return 0;
}

Thank you, teacher says we use online programming environment can't use void main ()

CodePudding user response:

All that will void to int,
  • Related