use scanf("%d %d %d",var,&var,var);
Although it's not a good idea, because it can mess some other data :
Code:
// ----------------------------------------------------------------
// File : main.cpp
// Date & Time : 8/30/2001 12:05:53 PM
// Description : Test application for scanf() when passed values instead of addresses
// Notes : None
// Compiler : Microsoft Visual C++ 6.0
// OS : Microsoft Windows 2000 proffessional
// App Mode : Console
// ----------------------------------------------------------------
// ----------------------------------------------------------------
// Headers
//
// getch()
#include <conio.h>
// printf(),scanf()
#include <stdio.h>
// ----------------------------------------------------------------
// Name : main
// Access : public
// Ret : int
// Desc : App entry in general, and it's the whole app here
// ----------------------------------------------------------------
int main()
{
int iData = 20;
// Assign address of iData to iInput, this could happen with uninitialized variables
// So assume this happened randomly.
int iInput = (int)(&iData);
// Output iData before messing its contents
printf("iData = %d\n",iData);
// Prompt for input
printf("Enter 3 numbers separated by spaces : ");
// Get the input, use the address of iInput for the middle number
scanf("%d %d %d",iInput,&iInput,iInput);
// Echo the number we got
printf("%d was extracted\n",iInput);
// Output the messed iData
printf("iData = %d, Press anykey to continue",iData);
// Wait for a keypress
getch();
// Done
return 0;
}
A typical run :
iData = 20
Enter 3 numbers separated by spaces : 0 15 30
15 was extracted
iData = 30, Press anykey to continue