How can I return a string to the operating system in my C code?

前端 未结 6 489
星月不相逢
星月不相逢 2020-12-16 04:14

I am a C beginner and this is my C code:

#include 
#include 

main()
{
    printf(\"Hello, World!\\n\");
    return \'sss\';
}         


        
6条回答
  •  抹茶落季
    2020-12-16 04:29

    You don't return a string. Applications exit with an integer exit code.

    Conventionally, exiting with a return of 0 will always show that your application exited without error / completed. You return an integer other than 0 to show that your application exited abnormally.

    You could throw an exception and handle it with a logging method higher in the call stack, or you could just return something other than 0 and make sure you had it documented in your release notes as to what each error integer means.

提交回复
热议问题