[英]Reading line with spaces in C Programming and segmentating the words
我有类似于以下的输入:
约翰希 ID5 409-208
我需要能够读取输入并在如下结构上组织 output:
姓名:强希
类型:ID5
身份证号码:409-208
但我正在努力寻找有关如何使用空格处理片段的文献。 我承认,我对 C 很陌生。
声明具有适当长度的变量,并且:
scanf("%s %s %s", name, type, id);
这是你想要的那种东西吗?
#include <stdio.h>
#include <string.h>
int main()
{
char mstring[] = "Hello World";
char space = ' ';
int a = 0;
while ( a < strlen(mstring))
{
if (mstring[a] == space)
{
printf ("found space!");
}
a++;
}
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.