2017-02-22 13 views
0

は、だからここに私のコードです:文字列内の文字を置き換えて編集する方法は?

main() 
{ 
     char input[150];                  //Create a variable of type char named input to store user input 

     printf(" Enter a standard line: ");              //Ask the user for some standard input 

     if (fgets(input, 150, stdin) == NULL)             //Initiate a series of checks to make sure there is valid input 
     { 
       puts(" End-of-File or Input Error Detected. ");         //If the end of the file is reached or there is a problem with input output a message 
     } 
     else if (input[0] == '\n')                //If the user neglected to enter anything output a message 
     { 
       puts(" Oops! Looks like you forgot to enter something! "); 
     } 
     else 
     { 
       printf(" Here's what you entered: %s ", input);         //If there is valid user input echo it back to the user 

       while (input[0] != '\n') 
       { 

         (can I put the while loop here?) 
       } 
     } 
} 

私はちょうど私のコードを実行するようになった(ここでStackOverflowの上Chuxの礼儀)と、今私は別の問題を抱えています。入力があることを確認できるようになりましたので、特定の文字をASCIIコードに置き換えたり、アルファベットの文字の場合を変更したり、行を折り返したりして、入力行を置き換えて調整する必要があります。 1.ユーザ入力:google.COM/search?clientバックユーザへとして
2プログラムの変更と印刷:私はそれを行うにはどうすればよいGOOGLE.com%2FSEARCH%3FCLIENT

例えば

? whileループをそのまま残すことはできますか?

+0

は、より具体的にループ内で私を増加しようとするのは、あなたの入力は[0] \に等しいとしましょうnは、このループは永遠に続きますあなたの質問にお願いします。 –

+0

@kishanoza私はかなり具体的だと思った。それとも、私はそれが何をすべきかの例を入れなければならないということを意味しましたか? – Polly

+0

正確に例を入れてください –

答えて

0

あなたはこれを使用しないでください----> while(input [0]!= '\ n');

ので、多分入力[I]!=「\ nの」のようにそれを行うと

関連する問題