I run the adhering to C codes and got a warning: regulate reaches end of non-void function

int main(void) Any suggestions?


*

*

Just put return 0 in your main(). Your function major retransforms an int (int main(void)) therefore you have to include a rerevolve in the end of it.

You are watching: Control reaches end of non-void function c++

Control reaches the finish of a non-void function

Problem: I obtained the complying with warning:warning: manage reaches finish of non-void function

Solution: This warning is comparable to the warning defined in Rerotate through no worth. If manage reaches the end of a role and also no rerotate is encountered, GCC assumes a rerevolve with no rerotate worth. However before, for this, the function calls for a return value. At the end of the feature, include a return statement that retransforms a suitable rerotate worth, even if regulate never before reaches tbelow.

source

Solution:

int main(void) my_strcpy(strB, strA); puts(strB); return 0;
Share
Improve this answer
Follow
edited Oct 28 "14 at 21:39

*

ChrisN
15.9k88 gold badges5454 silver badges7575 bronze badges
answered Nov 19 "12 at 23:28
*

dreamcrashdreamcrash
37.9k2323 gold badges6565 silver badges9090 bronze badges
0
Add a comment |
13
As an different to the obvious solution of including a rerevolve statement to main(), you can usage a C99 compiler (“gcc -std=c99” if you are utilizing GCC).

In C99 it is legal for main() not to have actually a rerevolve statement, and then the last } implicitly retransforms 0.

$ gcc -c -Wall surface t.ct.c: In feature ‘main’:t.c:20: warning: manage reaches end of non-void function$ gcc -c -Wall -std=c99 t.c$ A note that purists would think about important: you need to not deal with the warning by declaring main() as returning kind void.


Share
Improve this answer
Follow
edited Nov 19 "12 at 23:42
answered Nov 19 "12 at 23:32
*

Pascal CuoqPascal Cuoq
75.9k66 gold badges146146 silver badges263263 bronze badges
0
Add a comment |
3
The major function has actually a return-form of int, as shown in

int main(void)but your primary feature does not rerotate anything, it closes after

puts(strB);Add

rerotate 0;after that and also it will job-related.


Share
Improve this answer
Follow
answered Nov 19 "12 at 23:28
KninnugKninnug
7,84211 gold badge2727 silver badges4040 bronze badges
Add a comment |

Your Answer


Thanks for contributing a response to Stack Overflow!

Please be sure to answer the question. Provide details and also share your research!

But avoid

Asking for help, clarification, or responding to various other answers.Making statements based upon opinion; earlier them up via recommendations or personal experience.

To learn even more, view our tips on writing great answers.

See more: Kylie Jenner Yellow Dress Off 61%, Kylie Jenner: Tube Mini Dress, Yellow Sandals


Draft saved
Draft discarded

Sign up or log in


Sign up making use of Google
Sign up making use of Facebook
Sign up using Email and Password
Submit

Message as a guest


Name
Email Required, however never before shown


Message as a guest


Name
Email

Required, but never shown


Article Your Answer Discard

By clicking “Message Your Answer”, you agree to our regards to organization, privacy policy and cookie policy


Not the answer you're looking for? Browse various other concerns tagged c or ask your own question.


The Overcirculation Blog
Featured on Meta
Visit chat
Linked
4
Mechanism for returning a string from C main() program
0
Why execute I get the warning 'regulate reaches finish of non-void function' even as soon as the return is guaranteed
Related
3141
Improve INSERT-per-second performance of SQLite
0
warning: manage reaches finish of non-void attribute
2
warning: manage reaches finish of non-void feature (gtk)
8
C - control reaches finish of non-void function
Hot Network Questions even more hot concerns

Question feed
Subscribe to RSS
Question feed To subscribe to this RSS feed, copy and also paste this URL into your RSS reader.


lang-c
Stack Overflow
Products
Company kind of
Stack Exadjust Network
website architecture / logo © 2021 Stack Exadjust Inc; user contributions licensed under cc by-sa. rev2021.9.9.40167


Stack Overcirculation works best with JavaScript enabled
*

Your privacy

By clicking “Accept all cookies”, you agree Stack Exreadjust deserve to save cookies on your device and discshed information in accordance with our Cookie Policy.