问题描述
我正在开发一个数据库基础项目
考虑一个结构
i am working on a database basic project
consider a structure
struct student
{
int rollno;
char full_name[20];
char address[50];
char birthmark[50];
};
如何获取此输入
rollno 6
名字john snow
地址winterfell of north
胎记剑全部伤害
什么我试过了:
i尝试过scanf(%s,stringname),scanf(%[^ \ n] s,stringname ),获取(stringname),
fgets(缓冲区,大小,标准差)与fflush stdin。
总有一些错误。
so far fgets工作得很好但是我读过ffush(stdin)是一种错误的做法。
所以应该同时输入字符串(带空格)的方法在另一个之后
how to take this input
rollno 6
name john snow
address winterfell of north
birthmark swords wound all over
What I have tried:
i have tried scanf("%s",stringname),scanf("%[^\n]s",stringname),gets(stringname),
fgets(buffer,size,stdin) with fflush stdin.
there are always some error.
so far fgets work perfectly but i have read ffush(stdin) is a wrong practice .
so what should be the approach to take input of string (with spaces) simultaneously one after the another
推荐答案
这篇关于怎么采取多个字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!