猫猫球团团 2021-11-17 16:08 采纳率: 71.4%
浏览 1638
已结题

c语言程序出现警告,[Warning] extended initializer lists only available with -std=c++11 or -std=gnu++11


#include <stdio.h>
#include <string.h>
#define density 62.4
int main()
{
    float weight, volume;
    int size, letters;
    char name{40};
    printf("Hi!What's your first name?\n");
    scanf("%s", name);
    printf("%s,What's your weight in ponds?\n", name);
    scanf("%f", &weight);
    size = sizeof(name);
    letters = strlen (name);
    volume = weight / density;
    printf("Well, %s, your volume is %2.2f cubic feet.\n", name, volume);
    printf("Also, your first name name has %d letters, \n", letters);
    printf("and we have %d bytes to store it.\n", size);
    
    return 0;
 } 

出现警告,[Warning] extended initializer lists only available with -std=c++11 or -std=gnu++11
如何解决?

  • 写回答

1条回答 默认 最新

  • 与春风 2021-11-17 16:13
    关注
    char name{40}; 语法错误?
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 3月11日
  • 已采纳回答 3月11日
  • 创建了问题 11月17日