[英]C hello world program is crashing on variable output
To start off, I'm coming off from ac# background, so I do have a knowledge on intermediate programming. 首先,我来自ac#背景,所以我对中间编程有一定的了解。
So this is my first C program, and when I try to print the variable "testtt" it crashes. 这是我的第一个C程序,当我尝试打印变量“ testtt”时,它崩溃了。
#include <stdio.h>
#include <stdlib.h>
int main()
{
char testtt = "Hello world";
//scanf("%s", &test);
printf(testtt);
return 0;
}
char
only holds one character. char
仅包含一个字符。 Use char testtt[] = "Hello world";
使用char testtt[] = "Hello world";
Change 更改
char testtt = "Hello world";
to 至
char testtt[] = "Hello world";
我认为printf也应该是:
printf("%s", testtt);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.