How to enter a string n number of times in C using scanf() -


i'm trying enter no of test cases (t) , n number of times enter string , process it. here's code tried:

    char str[10000];     int size,flag,i,t;     scanf("%d",&t);     while(t--){         gets(str);         flag=1;         size=0;         while(str[size]!='\0')  size++;         if(size<2)  flag=0;         for(i=0;i<size/2;i++)             if(abs(str[i+1]-str[i])!=abs(str[size-i-1]-str[size-i-2]))  flag=0;         if(flag)    printf("funny\n");         else        printf("not funny\n");     } 

also in place of using gets, tried:

scanf("%[^\t\n]s",str); 

but nothing seems work

actually, got it.

    int t;     char str[100];     scanf("%d",&t);     while(t--)         scanf("%s",str); 

this works fine.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -