how does one write a code so that it takes down 2 values on a printf (example:
Wind Calculator
Enter MILES and FEET traveled: 1 1000
Enter number of MINUTES and SECONDS elapsed: 1 28
how does one write a code so that it takes down 2 values on a printf (example:
Wind Calculator
Enter MILES and FEET traveled: 1 1000
Enter number of MINUTES and SECONDS elapsed: 1 28
are you talking about scanf? It looks like you want to input two values.
scanf("%d %d",&val1,&val2);
i have that for scanf... but would i need to do anything for printf (or does it just ASSUME that you need to punch in 2 values... ???
printf("Value one: %d, value two: %d", &val1, &val2);
gcc -lalleg
http://www.ciusa.net/~jrgrant/
Code:#include<stdio.h> int main() { int iNum = 10; //variable used to hold an integer printf("The number is: %d", iNum); return 0; }
printf takes the name of the variables and not their addresses, I think.Code:printf("Value one: %d, value two: %d", &val1, &val2);
I go to encounter for the millionth time the reality of experience and to forge in the smithy of my soul the uncreated conscience of my race.
Windows XP consists of 32 bit extensions and a graphical shell for a 16 bit patch to an 8 bit operating system originally coded for a 4 bit microprocessor, written by a 2 bit company, that can't stand 1 bit of competition.
For numbers, fyodor is correct... this should have beenOriginally posted by fyodor
printf takes the name of the variables and not their addresses, I think.Code:printf("Value one: %d, value two: %d", &val1, &val2);
>printf("Value one: %d, value two: %d", val1, val2);
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
%d in printf does indeed specify an integer so the "&" is not needed. I always say " the address of" when I type code thatprintf("Value one: %d, value two: %d", &val1, &val2);
contains the "&" with a variable. Seems to help me.
There are many good definitions of "printf" formats and their arguments in K&R.