❶ 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)再试试看能不能执行到。