高崇文的aroma 2016-11-06 07:31 采纳率: 100%
浏览 2770
已采纳

编译显示成功,但生成时显示Project1.exe已停止工作

#define STDC_WANT_LIB_EXT1 1
#include
#include
int main()
{
char str1 = "to or not to be.";
printf("the string:\n \"%s\"\ncontains %zu characters and %zu bites.",str1,strnlen_s(str1,sizeof(str1)), sizeof(str1));

return 0;

}

  • 写回答

1条回答

  • RLHaides 2016-11-06 08:38
    关注
    #include<stdio.h>
    #include<string.h>
    int main(){
        char str[]="to be or not to be";
        printf("the string:\n%s\n",str);
        printf("contains %d characters and %d bites",strlen(str),sizeof(str));
        return 0;
    }
    
    

    效果图片说明
    不建议将太多的东西放在一起,可以适当的分开,增强可读性。
    而且你的strlen用的不是很对

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?