Note that there are some explanatory texts on larger screens.

plurals
  1. POProcessing outputs of multiple inputs in C
    primarykey
    data
    text
    <p>It's not something trivial but I would like to know the best way to process multiple outputs, for example:</p> <p>Input </p> <p>First line of input will contain a number T = number of test cases. Following lines will contain a string each. </p> <p>Output </p> <p>For each string, print on a single line, "UNIQUE" - if the characters are all unique, else print "NOT UNIQUE"</p> <p>Sample Input </p> <pre><code> 3 DELHI london #include&lt;iostream&gt; </code></pre> <p>Sample Output </p> <pre><code> UNIQUE NOT UNIQUE NOT UNIQUE </code></pre> <p>So how can I accomplish outputs like that? My code so far is:</p> <pre><code> int main(int argc, char *argv[]) { int inputs, count=0; char str[100]; char *ptr; scanf("%d",&amp;inputs); while(inputs-- &gt;0) { scanf("%s",str); for(ptr=str; *ptr!='\0';ptr++) { if( *ptr== *(ptr+1)) { count++; } } if(count&gt;0) { printf("NOT UNIQUE"); } else { printf("UNIQUE"); } } } </code></pre> <p>But the above will obviously print the output after each input, but I want the output only after entering all the inputs, if the user enters 3, then the user have to give 3 strings and after the output will be given whether the given strings are unique or not. So I want to know how can I achieve the result given in the problem. Also another thing I want to know is, I am using an array of 100 char, which it can hold a string up to 100 characters, but what do I have to do if I want to handle string with no limit? Just declaring char *str is no good, so what to do? </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload