請各位大大幫我看C語言程式有沒有錯或需要改進的地方

Home Home
引用 | 編輯 isaacfong
2007-10-14 22:58
樓主
推文 x0
各位大大 小弟我剛接觸C語言 正在看書學習中 由於我使用的書 習題並無解答
所以才想麻煩各位大大幫我看一看
感恩!!

這題題目是 寫 ..

訪客只能看到部份內容,免費 加入會員



獻花 x0
引用 | 編輯 akole
2007-12-04 21:13
1樓
  
void main(void)
{
  int a; <===a宣告為int
  while((a=getchar()) != EOF) <====結果擷取自元??????
  my_puts(a);
}

void my_puts() <===丟到不用回傳的函式,也沒傳入,也沒接收
{
  int c; 又一個宣告C
  while((c=getchar()) != EOF) <===哪時候擷取到阿
  putch(c); <====丟進去的又是哪個,好怪喔

}


是我觀念錯了,還是真的是要這樣子寫阿~~~~~~~~~~~~~?????

獻花 x0
引用 | 編輯 isaacfong
2007-12-17 16:16
2樓
  
自解........

#include<stdio.h>
#include<string.h>

char my_puts( char * input )
    {
        int i ;

        for( i=0; input != '\0' ; i++ )
              putchar( input ) ;

    }
       

int main( void )
    {
        char input[100] ;

        puts("Enter a staring : ");
        fgets( input , sizeof(input) , stdin );

        my_puts( input );

        return 0;
    }

獻花 x0