collect string in loop and printout all the string outside loop

Posted by user1508163 on Stack Overflow See other posts from Stack Overflow or by user1508163
Published on 2012-07-07T03:03:34Z Indexed on 2012/07/07 3:15 UTC
Read the original article Hit count: 256

Filed under:
|
|
|

I'm newbie here and there is some question that I want have some lesson from you guys. For example:

#include <stdio.h>
#include<stdlib.h>
#include<ctype.h>

void main()
{
    char name[51],selection;

    do
    {

    printf("Enter name: ");
    fflush(stdin);
    gets(name);
    printf("Enter another name?(Y/N)");
    scanf("%c",&selection);
    selection=toupper(selection);
    }while (selection=='Y');
                     //I want to printout the entered name here but dunno the coding
printf("END\n");
system("pause");
}

As I know when the loops perform will overwrite the variable then how I perform a coding that will printout all the name user entered? I have already ask my tutor and he is ask me to use pointer, can anyone guide me in this case?

© Stack Overflow or respective owner

Related posts about string

Related posts about pointers