c语言输入hello worldf返回world hello
时间: 2023-07-25 21:16:00 浏览: 42
以下是一个将输入的字符串反转顺序的 C 代码示例:
```
#include <stdio.h>
#include <string.h>
int main() {
char str[100];
int len, i, j;
printf("请输入字符串:");
scanf("%s", str);
len = strlen(str);
for(i = 0, j = len - 1; i < j; i++, j--) {
char temp = str[i];
str[i] = str[j];
str[j] = temp;
}
printf("反转后的字符串为:%s\n", str);
return 0;
}
```
在输入 "hello world" 后,程序会输出 "dlrow olleh"。
相关问题
用c语言输入hello world
在C语言中,可以使用printf函数来输出"Hello World"。下面是一个简单的示例代码:
```c
#include <stdio.h>
int main() {
printf("Hello World\n");
return 0;
}
```
这段代码首先包含了stdio.h头文件,该头文件中包含了printf函数的声明。然后,在main函数中,使用printf函数打印出"Hello World"。最后,通过return语句返回0,表示程序正常结束。
用c语言输入hello world !
当使用C语言编写程序时,可以使用标准库函数`printf`来输出字符串。下面是一个简单的示例代码,用于在控制台输出"Hello World":
```c
#include <stdio.h>
int main() {
printf("Hello World\n");
return 0;
}
```
在上述代码中,`printf`函数用于输出字符串,`\n`表示换行。通过调用`printf`函数并传入要输出的字符串作为参数,即可在控制台输出"Hello World"。最后的`return 0`语句表示程序正常结束。