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

前端 未结 6 505
星月不相逢
星月不相逢 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:22

    Sadly there is no way to do that.

    You could add something to the end of your C program like:

    int main()
    {
        int err = 0; // 0 is "success" is most C programs
        printf("Hello, World!!\n");
    
        switch( err )
        {
          case 0:
            printf("Program shutdown successfully!\n");
            break;
          case 1:
            printf("We had an issue somewhere. Please fix your input data\n");
            break;
          //case 2, 3, etc...
        };
    
       return err;
    }
    

提交回复
热议问题