I run the complying with C codes and got a warning: manage reaches end of non-void function

int main(void) Any suggestions?


*

*

Just placed return 0 in your main(). Your function main returns an int (int main(void)) as such you should include a return in the end of it.

You are watching: Warning: control reaches end of non-void function

Control reaches the finish of a non-void function

Problem: I received the following warning:warning: control reaches end of non-void function

Solution: This warning is comparable to the warning defined in Return with no value. If manage reaches the end of a duty and no return is encountered, GCC assumes a return with no return value. However, because that this, the duty requires a return value. At the finish of the function, add a return statement that returns a an ideal return value, even if regulate never reaches there.

source

Solution:

int main(void) my_strcpy(strB, strA); puts(strB); return 0;
re-superstructure
boost this answer
follow
edited Oct 28 "14 in ~ 21:39

*

ChrisN
16k88 gold badges5454 silver badges7676 bronze title
reply Nov 19 "12 at 23:28
*

dreamcrashdreamcrash
38.8k2323 gold badges7070 silver badges9595 bronze title
0
add a comment |
13
As an alternative to the noticeable solution of including a return statement come main(), you have the right to use a C99 compiler (“gcc -std=c99” if you are using GCC).

In C99 it is legal because that main() no to have actually a return statement, and then the final } implicitly returns 0.

$ gcc -c -Wall t.ct.c: In role ‘main’:t.c:20: warning: control 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 solve the warning by proclaiming main() as returning type void.


re-superstructure
boost this answer
follow
edited Nov 19 "12 at 23:42
answer Nov 19 "12 in ~ 23:32
*

Pascal CuoqPascal Cuoq
76.6k77 yellow badges150150 silver- badges269269 bronze badges
0
include a comment |
3
The main duty has a return-type the int, as indicated in

int main(void)however her main function does not return anything, it closes after

puts(strB);Add

return 0;after that and it will certainly work.


re-publishing
boost this answer
follow
reply Nov 19 "12 at 23:28
KninnugKninnug
7,87211 gold badge2727 silver badges4141 bronze title
add a comment |

your Answer


Thanks for contributing response to stack Overflow!

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

But avoid

Asking for help, clarification, or responding to other answers.Making statements based on opinion; ago them increase with references or an individual experience.

To learn more, view our tips on writing an excellent answers.

See more: How Many Gallons In A Barrel Of Jack Daniels By The Barrel, Finished Empty Jack Daniel'S Branded Barrel


Draft saved
Draft discarded

Sign increase or log in


authorize up utilizing Google
sign up making use of Facebook
authorize up utilizing Email and also Password
submit

Post together a guest


name
email Required, however never shown


Post together a guest


name
email

Required, but never shown


short article Your prize Discard

By click “Post your Answer”, you agree come our regards to service, privacy policy and cookie policy


Not the prize you're feather for? Browse other questions tagged c or ask your very own question.


The Overflow Blog
Featured on Meta
Linked
4
Mechanism for returning a string from C main() program
0
Why execute I get the warning 'control reaches end of non-void function' also when the return is guaranteed
connected
3168
boost INSERT-per-second performance of SQLite
0
warning: manage reaches finish of non-void role
2
warning: manage reaches end of non-void function (gtk)
8
C - control reaches end of non-void duty
hot Network concerns much more hot questions

question feed
subscribe to RSS
inquiry feed To i ordered it to this RSS feed, copy and paste this URL into your RSS reader.


lang-c
ridge Overflow
products
firm
stack Exchange Network
site design / logo © 2021 ridge Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.12.22.41046


Stack Overflow works ideal with JavaScript enabled
*

your privacy

By clicking “Accept every cookies”, you agree stack Exchange can store cookies on your machine and disclose information in accordance v our Cookie Policy.