c programme 問題

想問下點可以用loop指令使到可以不停輸入,即係好似咁

input a character:<--之後輸入者入完會顯示番入左咩

scanf("%c,&nu);<---呢到我無問題

但點可以用loop等個programme自己loop番去重新再問一次,等輸入者可以再輸入data?thx~

2 Answers

Rating
  • 8 years ago
    Favorite Answer

    tips#1: your loop must require some condition....

    tips#2: store all the inputs to an array?

    because how many data you are required?

    or waiting for this one answer?

    there must be some exit somewhere.....

    a while (true) loop is dangerous.... just keep looping without stopping the program...

  • 8 years ago

    you can try as follow:

    void main

    {

    char arrInput[256];

    while(1)

    {

    printf( "Input a character:");

    scanf( "%s", arrInput);

    printf( "Your input: %s\n\n", arrInput);

    }

    }

Still have questions? Get your answers by asking now.