當前位置:首頁 » 編程語言 » c語言進不了函數
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

c語言進不了函數

發布時間: 2022-10-11 03:16:34

c語言,調用不了函數

函數要先聲明後使用。函數正確定義之後,還要看語法或演算法是否有錯誤,而導致調用該函數的語句未執行

❷ 關於C語言的問題。編譯沒有問題,就是運行時進不了插入刪除函數!程序如下:

#define maxsize 100 #include typedef struct{ int a[maxsize]; int len; }sqlist; sqlist *create(){ sqlist *L; int i,n; printf("please enter a number thayt will dicide the room of the array\n"); scanf("%d",&n); if(n<0||n>maxsize)printf("You have enter a illagle number,please enter again!"); else { printf("now create the array :\n"); for(i=0;i<=(*L).len;i++) { printf(" a[%d]=%d",i,(*L).a[i]); } printf("\n"); } return L; } void insert(sqlist *L,int loca,int number){ int j,i; if(loca<0||loca>(*L).len)printf("Wrong location!") ; else { for(j=(*L).len;j>=loca;j--) (*L).a[j+1]=(*L).a[j]; (*L).a[loca]=number; (*L).len=(*L).len+1; printf("The new array is :"); for( i=0;i<(*L).len;i++) printf(" a[%d]=%d: ",i,(*L).a[i]); } } int del(sqlist *L,int loc){ int i,k; if((*L).len=0){printf("This is a empty list!");return -1;} else { if(loc<0||loc>(*L).len){printf("wrong location!");return 0;} else { printf("The location you want to delete is: /n and the number you want to is : %d",loc,(*L).a[loc]); for( k=loc;k<(*L).len;k++) (*L).a[k-1]=(*L).a[k]; (*L).len=(*L).len-1; printf("The new array is :"); for( i=0;i<(*L).len;i++) { printf(" a[%d]=: ",i); printf("%d ",(*L).a[i]); } return 1; } } } void main(){ sqlist *L; int q,location,num; char c; L=create(); printf("if you want to insert a number,please enter I\n"); printf("if you want to delete a number,please enter D\n"); c=getchar(); scanf("%c",&c); if(c=='I'||c=='i') { printf("please enter the location: "); scanf("%d",&location); printf("\n"); printf("Enter the nunber that you want to insert:"); scanf("%d",&num); insert(L,location,num); } else if(c=='D'||c=='d') { printf("Enter the location you want to delete :"); scanf("%d",&location); q=del(L,location); switch(q) { case -1:printf("Delete fail!");break; case 0 :printf("Delete fail because of wrong position!");break; case 1:printf("Delete complete!");break; } } else printf("Now I am going to do nothing!"); }

這些你再檢查一下

❸ 在c語言中用不了函數,怎麼回事

函數先使用後定義了。


C語言要求調用某一個函數之前,一定要知道該函數的定義。


兩者修改方法:

//一、將函數的定義放在調用之前,這樣調用的時候就知道該函數的定義了
#include<stdio.h>

voidcheer(){
printf("cheer");
}
intmain(){
cheer();
}

//二、在調用函數之前,顯示聲明該函數的類型
#include<stdio.h>

intmain(){
voidcheer();
cheer();
}

voidcheer(){
printf("cheer");
}

❹ C語言 不能調用函數

你的input執行之後,就判斷退出了的。

因為你的input函數的參數是TS, 是結構體,而不是結構體指針,因此,在input裡面得到的結果,只是input裡面局部變數的M這個結構體得到了值,並沒有賦值給M1和M2,導致你那裡判斷M1.n M2.m的時候,直接return 0了

不謝^-^

❺ C語言編程編譯沒問題 但進入不到主函數

死循環了,在
printf("dasdw");
//
運行後輸出不了!
後面加上這個,
getchar();
dasdw列印出來了,然後while循環就一直做

❻ 為什麼我的c語言不能使用函數呢

在函數中(包括主函數)不能定義和函數名相同的變數,一般情況下函數名的定義需要有實際意義,讓編程者能一看便知函數的功能(變數也是這樣),如果是需要多個單詞才能表達意思就使用下劃線連接兩個或多個單詞,或者直接寫在一起每個單詞首字母大寫,這樣定義主要是為了讓程序看起來更加簡潔明了,讓其他人能迅速了解程序功能,便於修改

❼ C語言 函數無法調用

#include<stdlib.h>
#include<stdio.h>
int main()
{
int x,z;
int add1(x);//聲明用函數原型,int add1(int x);
scanf("%d",&x);
z=add1(x); /*顯示在這里出錯,說是不能使用函數*/
printf("%d",z);
system("pause");
return 0;}
int add1(x)//定義帶形參的函數,形參要有類型,正確的 int add1(int x)
{int x,y;//x形參中定義過了,不需要再定義直接寫int y;就可以了
y=1+x;
return y;
}
呵呵,修改已經在注釋中給出,你對照修改下就好了
繼續努力呀,我也對c語言比較感興趣,有空多多交流....

❽ 單片機C語言編程 進入不了主函數的while(1)循環

timer_Src的值是如何改變的,會不會有3、4、5的值出現。你可以在switch(timer_Src)前面插一對timer_Src進行賦值語句(如等於3)再試試看能不能執行到。