C programing: scanf dont read :(
#1

new POST EDIT=============SOLVED
new error with c, this time imade test why i get allways answer 0.. and i made test program which shows that all arguments after scanf =0
the code..
Код:
float a,b,c,x1,x2,D;  
  scanf("%f%f%f",&a,&b,&c); 
  printf("readed:\na= %f\nb= %f\nc= %f\n",&a,&b,&c); // that is eror must be printf("readed:\na= %f\nb= %f\nc= %f\n",a,b,c); fool me :-[
it prints me:
Код:
readed:
a=0.000000
b=0.000000
c=0.000000
also bump now cause old post was yesterday
help if you can



=================================
============OLD post solved==========
Please need help with C has anybody any idea how to make menu system look and you will understand, my script structure:
this one has error that i mentioned because it is abowe void menu
Код:
void calculator
this is menu vuid from where i call other voids and i want menu has links to every void and every other void should had a back link
Код:
void menu
this is main and here is loaded menu void and some messages
Код:
int main
hope understood, so i cant make links circle with voids, should i use some other call or add third void?
//===============edit no problem fixed destroyed circles
but now another proble i got crash even i try to sqare rise count or sqrt it
Код:
 float n1, n0;
  scanf("%s %f",m0,n1);
  if(strcmp(m0,"end")==0)exit(EXIT_SUCCESS); //iseiti
  else if(strcmp(m0,"square")==0)n0=n1*n1;  //sqare
  else if(strcmp(m0,"cube")==0)n0=n1*n1*n1;  //cube
  else if(strcmp(m0,"sqrt")==0)n0= sqrt(n1); //sqrt
  else                     //if none
  {
    printf("Bad symbol of format");
//that doesnt matter
....
}
//=======edit
fool me!

Quote:

scanf("%s %f",m0,n1);

should bee
Код:
scanf("%s %f",&m0,&n1);
Reply
#2

well, you better use gets instead of scanf
you can use simply
Код:
float a,b,c,x1,x2,D;  
  gets(a); 
  gets(b);
  gets©;
  printf("readed:\na= %f\nb= %f\nc= %f\n",&a,&b,&c);
and if you still like to use scanf you have to do
Код:
float a,b,c,x1,x2,D;  
  scanf("%f",&a); 
  scanf("%f",&b); 
  scanf("%f",&c); 
  printf("readed:\na= %f\nb= %f\nc= %f\n",&a,&b,&c);
hope that help you
Reply
#3

but with scanf you can scan like line with one enter button pres i found error fool me again at printf("deasnt need %f that & symbol only in scanf", a); sorry your way als will show 0.00 cause prinnf is writen mistakefully like mine
Reply
#4

ah ye i've just copied and edited your code, maybe try this
Код:
float a,b,c,x1,x2,D;  
  scanf("%f",&a); 
  scanf("%f",&b); 
  scanf("%f",&c); 
  printf("readed:\na= %f\nb= %f\nc= %f\n",a,b,c);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)