Board logo

標題: C+++++ [打印本頁]

作者: 電腦神    時間: 2009-2-19 18:44     標題: C+++++

#include "stdio.h"
#include "stdlib.h"

int main(void)
{
        char A[100];
        scanf("%s", &A);
        system("ping %s",A);
        return 0;
}
點改可以做到類似以上既野=.=
error C2660: 'system' : function does not take 2 arguments
作者: thinkpanda    時間: 2009-2-19 19:26

原帖由 電腦神 於 2009-2-19 18:44 發表
#include "stdio.h"
#include "stdlib.h"

int main(void)
{
        char A[100];
        scanf("%s", &A);
        system("ping %s",A);
        return 0;
}
點改可以做到類似以上既野=.=
error C2660: 'system' : function d ...


google "sprintf"
作者: 電腦神    時間: 2009-2-19 20:28

原帖由 thinkpanda 於 2009-2-19 07:26 PM 發表


google "sprintf"


我唔係sprintf係system喎
作者: thinkpanda    時間: 2009-2-19 23:28

原帖由 電腦神 於 2009-2-19 20:28 發表


我唔係sprintf係system喎


咁你唔信我都無辦法...
作者: ntony    時間: 2009-2-19 23:48

原帖由 電腦神 於 2009-2-19 20:28 發表


我唔係sprintf係system喎



動下腦

#include "stdio.h"
#include "stdlib.h"

int main(void)
{
        char A[100];
        char command[105];
        scanf("%99s", A); //差D留意唔到你俾錯pointer + variable naming最好meaningful少少,叫佢做uri唔係好好多咩?
        sprintf(command, "ping %s", A);
        system(command);
        return 0;
}


真係唔明呢個年代D學生係點諗野既

[ 本帖最後由 ntony 於 2009-2-23 12:47 編輯 ]
作者: ntony    時間: 2009-2-19 23:48

唔小心重覆左

[ 本帖最後由 ntony 於 2009-2-19 23:48 編輯 ]





歡迎光臨 電腦領域 HKEPC Hardware (https://h0.hkepc.com/forum/) Powered by Discuz! 7.2