在C语言中,可以使用scanf函数来输入一行字符串,也可以使用gets函数或者fgets函数来输入一行字符串。 使用scanf函数输入一行字符串: char str[100]; // 声明一个字符串数组来存储输入的字符串 printf("请输入一行字符串:"); scanf("%[^\n]s", str); printf("输入的字符串是:%s\n", str); 复制代码 使...
include <stdio.h>#include <string.h>#include <stdlib.h>#define MaxSize 100int main(){ int i, num; scanf("%d", &num); FILE *fp = fopen("./data.txt", "r+"); //文件名自定 char str[MaxSize], tmp[MaxSize]; while(!feof(fp)) { memset(str...