c語言voidfileout,C語言運算符優先順序由高到低的順序

本文目錄一覽:

C語言中void out(int a[11],int j)的意思?

這只是一個函數的函數名和函數類型以及產這只是一個函數的函數名和函數類型以及參量表。從原則上說,並不能直接確定他是啥意思,但是按照慣例,這可能是一個輸出數組中j個元素的函數。

C語言如何輸出helloworld到FILE.out文件中

不同的ide對main函數有不同的要求,有些可以是void,有些必須要有返回值,你在你printf下面加一句return

0;或者任何整型就可以了。如果要窗戶停下需要包含頭文件stdlib.h,在return語句前加system(“pause”);

求公交線路查詢系統的c語言程序

這是我寫的程序 希望能給你參考

#includestdio.h

#includeconio.h

#includestdlib.h

#includestring.h

#define NULL 0

int n=0;

int aa[20]={0};

struct road

{long num;

char stage[20][20];

struct road *next;

};

struct road *create()

{struct road *head,*p1,*p2;

int m,i;

char yes_no;

FILE *fp,*fp1;

fp=fopen(“d:\\nizaoran.txt”,”w”);

if(fp==NULL)

{printf(“file cant be open\n”);

exit(1);

}

fp1=fopen(“d:\\record.txt”,”w”);

if(fp1==NULL)

{printf(“file can’t be open\n”);

exit(1);

}

head=NULL;

do

{p1=(struct road*)malloc(LEN);

printf(“please input %d num:”,n+1);

scanf(“%ld”,p1-num);

fprintf(fp,”%ld”,p1-num);

printf(“how many stages?”);

scanf(“%d”,aa[n]);

fprintf(fp1,”%d\n”,aa[n]);

for(i=0;iaa[n];i++)

{getchar();

printf(“please input the %d station:”,i+1);

gets(p1-stage[i]);

fprintf(fp,” %s”,p1-stage[i]);

}

fputc(‘\n’,fp);

p1-next=NULL;

n++;

if(n==1) head=p1;

else p2-next=p1;

p2=p1;

printf(“do you want to continue (Y/N)?”);

scanf(“%c”,yes_no);

}while(yes_no==’y’||yes_no==’Y’);

fclose(fp);

free (p1);

return head;

}

void add()

{

struct road temp;

int i=0;

FILE *fp;

fp=fopen(“d:\\nizaoran.txt”,”a”);

printf(“input the route you want to add:”);

scanf(“%ld”,temp.num);

fprintf(fp,”%ld”,temp.num);

printf(“please input how many stages:”);

scanf(“%d”,aa[n]);

while(iaa[n])

{getchar();

printf(“please input the %d stage\n”,i+1);

gets(temp.stage[i]);

fprintf(fp,” %s”,temp.stage[i]);

i++;

}

fprintf(‘\n’,fp);

n++;

fclose(fp);

}

void display()

{FILE *fp;

char ch;

if((fp=fopen(“d:\\nizaoran.txt”,”r”))==NULL)

{printf(“cant open file\n”);

exit(1);

}

while(!feof(fp))

{ch=fgetc(fp);

printf(“%c”,ch);

}

fclose(fp);

}

void modify()

{ FILE *fp;

struct road temp[20];

char a[6],b[20],ch;

int i=0,j=0,k=0,m=0,t=0;

long num;

if((fp=fopen(“d:\\nizaoran.txt”,”r”))==NULL)

{printf(“cant open file\n”);

exit(1);

}

for(i=0;in;i++)

{fscanf(fp,”%ld”,temp[i].num);

printf(“%ld “,temp[i].num);

for(j=0;jaa[i];j++)

{fscanf(fp,”%s”,temp[i].stage[j]);

putchar(‘ ‘);

puts(temp[i].stage[j]);

}

fgetc(fp);

}

fclose(fp);

printf(“which do you want to modify(num/stage)?”);

getchar();

gets(a);

if(strcmp(“num”,a)==0)

{printf(“which num:”);

scanf(“%ld”,num);

if((fp=fopen(“d:\\nizaoran.txt”,”w”))==NULL)

{printf(“cant open file\n”);

exit(1);

}

for(j=0;jn;j++)

if(temp[j].num==num)

{printf(“please input the right num:”);

scanf(“%ld”,temp[j].num);

break;

}

if(j==n) printf(“no find\n”);

}

else if(strcmp(“stage”,a)==0)

{if((fp=fopen(“d:\\nizaoran.txt”,”w”))==NULL)

{printf(“cant open file\n”);

exit(1);

}

printf(“the num and the stage:”);

scanf(“%ld%s”,num,b);

for(j=0;jn;j++)

{if(temp[j].num==num)

{ for(i=0;iaa[j];i++)

if(strcmp(temp[j].stage[i],b)==0)

{printf(“please input the right stage\n”);

getchar();

gets(temp[j].stage[i]);

break;

}

if(i==aa[j])

printf(“no fould”);

break;

}

}

if(j==n)

printf(“no found\n”);

}

for(i=0;in;i++)

{fprintf(fp,”%ld”,temp[i].num);

for(j=0;jaa[i];j++)

fprintf(fp,” %s”,temp[i].stage[j]);

fputc(‘\n’,fp);

}

fclose(fp);

}

void delete()

{FILE *fp;

long num;

struct road temp[20];

int i=0,j=0;

if((fp=fopen(“d:\\nizaoran.txt”,”r”))==NULL)

{printf(“cant open file\n”);

exit(1);

}

for(i=0;in;i++)

{fscanf(fp,”%ld”,temp[i].num);

printf(“%ld”,temp[i].num);

for(j=0;jaa[i];j++)

{fscanf(fp,”%s”,temp[i].stage[j]);

putchar(‘ ‘);

puts(temp[i].stage[j]);

}

fgetc(fp);

}

fclose(fp);

printf(“input the num you want to delete\n”);

scanf(“%ld”,num);

for(i=0;in;i++)

{

if(temp[i].num==num)

break;

}

if(i==n)

{printf(“no found\n”);

return;

}

else

{

temp[i].num=0;

}

fp=fopen(“d:\\nizaoran.txt”,”w”);

for(i=0;in;i++)

{

if(temp[i].num!=0)

{

fprintf(fp,”%ld”,temp[i].num);

printf(“%ld”,temp[i].num);

for(j=0;jaa[i];j++)

{fprintf(fp,” %s”,temp[i].stage[j]);

putchar(‘ ‘);

puts(temp[i].stage[j]);

}

fputc(‘\n’,fp);

putchar(‘\n’);

}

}

fclose(fp);

n–;

printf(“\n%d\n”,n);

}

void search_num()

{

FILE *fp;

struct road temp[20];

int i,j,i1=0,j1=0;

long num;

if((fp=fopen(“d:\\nizaoran.txt”,”r”))==NULL)

{printf(“cant open file\n”);

exit(1);

}

for(i=0;in;i++)

{fscanf(fp,”%ld”,temp[i].num);

printf(“%ld “,temp[i].num);

for(j=0;jaa[i];j++)

{fscanf(fp,”%s”,temp[i].stage[j]);

putchar(‘ ‘);

puts(temp[i].stage[j]);

}

fgetc(fp);

}

fclose(fp);

printf(“please input the number you want to search\n”);

scanf(“%ld”,num);

for(i1=0;i1n;i1++)

{if(temp[i1].num==num)

break;

}

if(i1n)

{ printf(“%ld”,temp[i1].num);

for(j1=0;j1aa[i1];j1++)

{putchar(‘ ‘);

puts(temp[i1].stage[j1]);

}

putchar(‘\n’);

}

else printf(“no found\n”);

}

void search_stage()

{

FILE *fp;

struct road temp[20];

int i,j,t,flag=0;

char a[20];

if((fp=fopen(“d:\\nizaoran.txt”,”r”))==NULL)

{printf(“cant open file\n”);

exit(1);

}

for(i=0;in;i++)

{fscanf(fp,”%ld”,temp[i].num);

printf(“%ld “,temp[i].num);

for(j=0;jaa[i];j++)

{fscanf(fp,”%s”,temp[i].stage[j]);

putchar(‘ ‘);

puts(temp[i].stage[j]);

}

fgetc(fp);

}

fclose(fp);

printf(“please input the stage you want to search\n”);

getchar();

gets(a);

for(i=0;in;i++)

for(j=0;jaa[i];j++)

if(strcmp(temp[i].stage[j],a)==0)

{printf(“%ld”,temp[i].num);

for(t=0;taa[i];t++)

{putchar(” “);

puts(temp[i].stage[t]);

}

putchar(‘\n’);

flag=1;

}

if(flag==0) printf(“no found\n”);

}

void search_route()

{

FILE *fp;

struct road temp[20];

int i,j,first=0,second=0,fir=0,sec=0;

char a[20],b[20];

if((fp=fopen(“d:\\nizaoran.txt”,”r”))==NULL)

{printf(“cant open file\n”);

exit(1);

}

for(i=0;in;i++)

{fscanf(fp,”%ld”,temp[i].num);

printf(“%ld “,temp[i].num);

for(j=0;jaa[i];j++)

{fscanf(fp,”%s”,temp[i].stage[j]);

putchar(‘ ‘);

puts(temp[i].stage[j]);

}

fgetc(fp);

}

fclose(fp);

printf(“please input the first stage\n”);

getchar();

gets(a);

printf(“please input the second stage\n”);

getchar();

gets(b);

for(i=0;in;i++)

for(j=0;jaa[i];j++)

{if(strcmp(temp[i].stage[j],a)==0)

{first=i;

fir=j;

}

if(strcmp(temp[i].stage[j],a)==0)

{second=i;

sec=j;

}

}

if(first==second)

{if(firsec)

{t=fir;

fir=sec;

sec=t;

}

printf(“%ld”,temp[first].num);

for(t=fir;t=sec;t++)

{ putchar(” “);

puts(temp[fisrt].stage[t]);

}

}

else printf(“not the same routine\n”);

}

void search()

{int i;

printf(“which way do you want(1,2,3):\n”);

scanf(“%d”,i);

switch(i)

{case 1 : search_num();break;

case 2 : search_stage();break;

case 3 : search_route();break;

}

}

void fileout()

{FILE fp1;

int i;

if((fp1=fopen(“d:\\recoord.txt”,”r”))==NULL);

{n=0;

for(i=0;i20;i++)

aa[i]=0;

}

else

{fscanf(fp1,”%d”,n);

for(i=0;i20;i++)

fscanf(fp1,” %d”,aa[i]);

}

fclose(fp1);

}

void filein()

{FILE fp1;

int i,count=0;

if((fp1=fopen(“d:\\recoord.txt”,”r”))==NULL)

{printf(“file cant be opened\n”);

exit(1);

}

else {fprintf(fp1,”%d”,n);

for(i=0;i20;i++)

if(aa[i]0)

{fprintf(fp1,” %d”,aa[i]);

count++;

}

if(count20)

for(i=count;i20;i++)

fprintf(fp1,”%d”,0);

}

fclose(fp1);

}

main()

{int choose;

char yes_no;

fileoout();

do

{clrscr();

printf(“\t ******************************\n”);

printf(“\t please input your choose(0~6):\n”);

printf(“\t ******************************\n”);

printf(“\t ********1-create route********\n”);

printf(“\t ********2-display route*******\n”);

printf(“\t ********3-search route********\n”);

printf(“\t ********4-modify route********\n”);

printf(“\t ********5-add route***********\n”);

printf(“\t ********6-delete route********\n”);

printf(“\t ********0-exit****************\n”);

printf(“\t input your choose:”);

scanf(“%d”,choose);

printf(“\n”);

switch(choose)

{case 1 : create();break;

case 2 : display();break;

case 3 : search();break;

case 4 : modify();break;

case 5 : add();break;

case 6 : delete();break;

case 0 : exit(0);

default: printf(“error”);

}

getchar();

printf(“\n do you want to continue to choose menu (y/n)?\n”);

do

{ yes_no=getchar();

}while(yes_no!=’Y’yes_no!=’y’yes_no!=’N’yes_no!=’n’);

}while(yes_no==’Y’||yes_no==’y’);

filiin();

}

c語言中的void

void 被翻譯為”無類型”,相應的void * 為”無類型指針”。常用在程序編寫中對定義函數的參數類型、返回值、函數中指針類型進行聲明。

void 的作用

1.對函數返回的限定,這種情況我們比較常見。

2.對函數參數的限定,這種情況也是比較常見的。

一般我們常見的就是這兩種情況:

(1)當函數不需要返回值值時,必須使用void限定,這就是我們所說的第一種情況。例如:void func(int a,char *b)。

(2)0當函數不允許接受參數時,必須使用void限定,這就是我們所說的第二種情況。例如:int func(void)。

擴展資料:

2011年10月12日,C語言之父丹尼斯·里奇辭世,在眾多的國際互動論壇上,計算機愛好者們以特有的方式紀念這位編程語言的重要奠基人。許多網友的發帖中沒有片言隻字,僅僅留下一個分號「;」。

在日益紛繁複雜的程序設計語言王國中,C語言因其簡潔、有效、通用的特性而始終佔據一席之地。被譽為「C語言之父」,同時也是操作系統Unix之父的C語言發明人之一——丹尼斯·里奇10月9日以70歲之齡辭世。

儘管通過Unix拿獎拿到手軟,但令里奇引起最大關注和反響的則是C語言的問世。1999年,里奇和湯普遜為發展C語言和Unix操作系統一起獲得了美國國家技術獎章。

參考資料:

百度百科-Void

百度百科-C語言關鍵字

原創文章,作者:IYBFT,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/330574.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
IYBFT的頭像IYBFT
上一篇 2025-01-16 15:46
下一篇 2025-01-16 15:46

相關推薦

  • AES加密解密演算法的C語言實現

    AES(Advanced Encryption Standard)是一種對稱加密演算法,可用於對數據進行加密和解密。在本篇文章中,我們將介紹C語言中如何實現AES演算法,並對實現過程進…

    編程 2025-04-29
  • 學習Python對學習C語言有幫助嗎?

    Python和C語言是兩種非常受歡迎的編程語言,在程序開發中都扮演著非常重要的角色。那麼,學習Python對學習C語言有幫助嗎?答案是肯定的。在本文中,我們將從多個角度探討Pyth…

    編程 2025-04-29
  • Python被稱為膠水語言

    Python作為一種跨平台的解釋性高級語言,最大的特點是被稱為”膠水語言”。 一、簡單易學 Python的語法簡單易學,更加人性化,這使得它成為了初學者的入…

    編程 2025-04-29
  • 條件運算符(?:)是什麼意思?

    條件運算符(?:)是JavaScript中的一種特殊的運算符,也是許多編程語言中相似語法的一部分。它可以允許我們在一個簡單、一行的語句中完成條件判斷和賦值操作,非常方便。 1.語法…

    編程 2025-04-29
  • OpenJudge答案1.6的C語言實現

    本文將從多個方面詳細闡述OpenJudge答案1.6在C語言中的實現方法,幫助初學者更好地學習和理解。 一、需求概述 OpenJudge答案1.6的要求是,輸入兩個整數a和b,輸出…

    編程 2025-04-29
  • Python按位運算符和C語言

    本文將從多個方面詳細闡述Python按位運算符和C語言的相關內容,並給出相應的代碼示例。 一、概述 Python是一種動態的、面向對象的編程語言,其按位運算符是用於按位操作的運算符…

    編程 2025-04-29
  • Python語言由荷蘭人為中心的全能編程開發工程師

    Python語言是一種高級語言,很多編程開發工程師都喜歡使用Python語言進行開發。Python語言的創始人是荷蘭人Guido van Rossum,他在1989年聖誕節期間開始…

    編程 2025-04-28
  • Python語言設計基礎第2版PDF

    Python語言設計基礎第2版PDF是一本介紹Python編程語言的經典教材。本篇文章將從多個方面對該教材進行詳細的闡述和介紹。 一、基礎知識 本教材中介紹了Python編程語言的…

    編程 2025-04-28
  • Python語言實現人名最多數統計

    本文將從幾個方面詳細介紹Python語言實現人名最多數統計的方法和應用。 一、Python實現人名最多數統計的基礎 1、首先,我們需要了解Python語言的一些基礎知識,如列表、字…

    編程 2025-04-28
  • Python作為中心語言,在編程中取代C語言的優勢和挑戰

    Python一直以其簡單易懂的語法和高效的編碼環境而著名。然而,它最近的發展趨勢表明Python的使用範圍已經從腳本語言擴展到了從Web應用到機器學習等廣泛的開發領域。與此同時,C…

    編程 2025-04-28

發表回復

登錄後才能評論