Concat, check sum of length, append, and print

**edit**

I have been given, and need assistance with a problem that asks for a querying loop to continue until the user says "No". The program should concatenate two strings, check that the sum of the lengths are no more than 80 chars, and then print each queried string and the final appended string.

So, when does the user input no? At any point during runtime? What is the result? Program termination?



Last edited on
There is no concept called a queering loop. Could it be that the author intended to write a form of 'query' ?..
And wouldn't it be easier to just ask the friend ?

As for learning backwards, you think you do, but you don't. Just try writing something and we'll say what can be improved.
No. I learn by deconstructing. Don't tell me what "I think", thanks. I taught myself many things by way of deconstruction.

I've sent him an email. I think it is probably a querying loop.
Why did you edit. Now I wouldn't be able to give you the code even if I wanted to..

Here's a loop which loops until you enter "no".
1
2
3
4
5
char input[10];
do{
   printf("do you want to continue? ");
   scanf("%s", input);
}while( strcmp(input, "no") != 0 );
I think. I rarely use c functions..
Should I repost the full problem?

Ahh. See, that's what I thought... the program needs to prompt a person for a no.

1. string1 is declared as char s1[80]. string2 is declared as s2[40]

2. Functions needs to check that the sum of both strings is less than 80 characters prior to appending them

3. If the sum is greater than 80 characters, return a NULL

4. Function call should print the total length of concatenated string.

5. Input strings should be collected using fgets(&s1[0], len1 + 1, stdin) and fgets(&s2[0], len2 + 1, stdin)
given len1 and len2 are the max. size of the respective input strings.

6. Output should print both input strings and then the final appended string.

7. The querying loop should continue until the user says "No".

So, what is the purpose of querying for no? To terminate the program?
Last edited on
The purpose of querying is that you may want to repeat the program several times and you want to be able to exit it.
Does one have to include an if statement for "yes"?
I don't think that is needed, though a random input allowing you to continue is a bit silly.
Don't worry much about the little things like this. Better concentrate on the algorithm itself..
Topic archived. No new replies allowed.