Reading multiple lines of input with scanf

前端 未结 4 489
时光取名叫无心
时光取名叫无心 2020-12-25 08:52

Writing a program for class, restricted to only scanf method. Program receives can receive any number of lines as input. Trouble with receiving input of multiple lines with

4条回答
  •  青春惊慌失措
    2020-12-25 09:39

    try this code and use tab key as delimeter

    #include 
    int main(){
        char s[100];
        scanf("%[^\t]",s);
        printf("%s",s);
    
        return 0;
    }
    

提交回复
热议问题