When i run, it just exit immediately...Code:#include<conio.h> main() { float A,B; printf("Input A :");scanf(A); printf("Input B :");scanf(B); if(B==0){ printf("%f, div Q is infinite \n",A); }else{ printf("%f div %f is %f \n", A,B,A/B);} } getch();
When i run, it just exit immediately...Code:#include<conio.h> main() { float A,B; printf("Input A :");scanf(A); printf("Input B :");scanf(B); if(B==0){ printf("%f, div Q is infinite \n",A); }else{ printf("%f div %f is %f \n", A,B,A/B);} } getch();
Well for starters, that doesn't actually compile. Try compiling with warnings on.
Quzah.
Hope is the first step on the road to disappointment.
I've compile that...
Perhaps you could read some documentation for that command.Code:scanf(A);
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
First off, fix your indentation. It's a pain to have to read code like that. Second off, your scanf() function will do two things: Firstly, the way it is written now, it will not compile. Secondly, should you get it to compile without changing how you pass in the variable, it will result in a segmentation fault.
scanf(A) is not going to compile, unless you force it to compile by completely removing the appropriate header, in which case it just won't work.
Now i got this error after this change
Warning --- possible use of 'A' before definition in function main
Code:#include<conio.h> main() { float A,B; printf("Input A :");scan(A); printf("Input B :");scan(B); if(B==0){ printf("%f, div Q is infinite \n",A); }else{ printf("%f div %f is %f \n", A,B,A/B);} } getch();
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
i'll try that,
thx...
Hope is the first step on the road to disappointment.
thats work!
thanks...
but after i input, this block like never exist(like doesnt work)?
but there was no warning,...
And how to put this, clrscr();Code:if(B==0){ printf("%f, div Q is infinite \n",A); }else{ printf("%f div %f is %f \n", A,B,A/B);} } getch();
I do this but give me error...
Code:#include<conio.h> main() { clrscr(); float A,B; printf("Input A :");scanf("%f", &A); printf("Input B :");scanf("%f", &B);
Last edited by nitediver; 10-01-2009 at 09:03 AM.
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
Sorry2...
Thats work, but...
I receive the result i the second time i run it...
C programming resources:
GNU C Function and Macro Index -- glibc reference manual
The C Book -- nice online learner guide
Current ISO draft standard
CCAN -- new CPAN like open source library repository
3 (different) GNU debugger tutorials: #1 -- #2 -- #3
cpwiki -- our wiki on sourceforge
the screenshot...
With Space
No Space
1.why i get "null" for the second output?Code:#include<stdio.h> main() { char *a,*b; int c; clrscr(); printf("Name : ");scanf("%s", a); printf("Class : ");scanf("%s", b); printf("Number : ");scanf("%d", &c); printf("Name : %s\n", a); printf("Class : %s\n", b); printf("Number : %d\n", c); getch(); }
2.why if i input more than 5 the number goes wrong?