精華區beta CSSE 關於我們 聯絡資訊
sorry 不過還感謝你的幫忙阿 ※ 引述《reader (讀者)》之銘言: : 開板公告就說過這裡不談程式除錯了,以後這類問題請到 : Programming 板或 C_and_CPP 板。 : 而且看起來你應該是想做 gets() 而不是 strcpy() 吧。 : 裡頭連結束條件都沒有,當然是結束不了。 : 以下是 MSDN 的 getchar() 範例,就自己看吧: : // crt_getc.c : /* This program uses getchar to read a single line : * of input from stdin, places this input in buffer, then : * terminates the string before printing it to the screen. : */ : #include <stdio.h> : int main( void ) : { : char buffer[81]; : int i, ch; : /* Read in single line from "stdin": */ : for( i = 0; (i < 80) && ((ch = getchar()) != EOF) : && (ch != '\n'); i++ ) : buffer[i] = (char)ch; : /* Terminate string with null character: */ : buffer[i] = '\0'; : printf( "Input was: %s\n", buffer ); : } : ※ 引述《bryanliu (jumping turtle)》之銘言: : : 這是我自己寫的 : : 不過沒有辦法像函式庫內的可以就直接結束掉 : : 有哪位大大可以教我 : : 把它改成一樣的作用 : : 謝謝摟 : : 以下是我的程式碼 : : #include<stdio.h> : : #include<conio.h> : : #include<string.h> : : int main() : : { : : char ch[1000]; : : int n,i; : : printf("please enter a string:\n"); : : printf("this is use getchar:"); : : n=strlen(ch); : : for(i=0;i<=n;i++){ : : ch[i]=getchar(); : : putchar(ch[i]); : : } : : return 0; : : } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.123.224.111