怎樣編寫乙個簡單的C語言程式的全過程

2021-05-26 13:58:10 字數 868 閱讀 6075

第一步:先在linux下運用#vi char.c建立乙個.c的文字。

在char.c中編寫你要實現的功能。我這裡用乙個最簡單的例子做說明。

#include

#include

main()

char str=123c@#fdsp[e?;

int i;

for(i=0 ; str[i]!=0; i++)

if(isalnum(str[i]))

printf("%c is an alphanumeric character\n", str[i]);

else

printf('%c is  not an alphanumeric character\n",str[i];

保成char.c文字。

第二步:在char.c同目錄中運用#vi makefile命今建立乙個makefile檔案

在makefile文字中輸入如下命令:

cross= arm-linux-

all: char

led:char.c

$(cross)gcc  -o char char.c

$(cross)strip char

clean:

@rm -vf char *.o *~

儲存makefile檔案。

第三步:執行#make all命令後在同目錄下生成char檔案。

如果出現「-/bin/sh: .char: permission denied」錯誤可能是沒有執行char的許可權

輸入#chmod 777 char

再輸入一次#./char執行char程式。

C語言 編寫的乙個簡單的Server Client

伺服器 include include pragma comment lib,ws2 32.lib 函式名稱 server 輸入引數 函式功能 void main 建立socket socket server server socket af inet,sock stream,ipproto tcp...

C 筆記 1 1 編寫乙個簡單的程式

每個c 程式都包含乙個或多個函式 function 其中乙個必須為main。作業系統通過呼叫main來執行c 程式。int main 乙個函式包含4個部分 返回型別 return type 函式名 function name 乙個括號包圍的形參列表 parameter list,允許為空 以及函式體...

乙個簡單的C語言程式HelloWorld

所謂萬事開頭難嘛,我們就先寫乙個最簡單的c語言程式來認識c語言吧!萬能的helloworld include int main void 下面進行講解上面的程式 include 預處理器指令,此處引用了stdio.h main 主函式,程式第乙個呼叫的函式 printf 格式化輸出資訊 return...