I have a function like this:
void getCommands( int commands[][ 2 ] )
{
int i, tempCommand;
printf( "Enter command ( 9 to end input ): " );
scanf( "%d", &tempCommand );
for ( i = 0; tempCommand != 9 && i < MAX; i++ )
{
commands[ i ][ 0 ] = tempCommand;
if ( tempCommand == 5 )
scanf( ",%d", &commands[ i ][ 1 ] );
printf( "Enter command ( 9 to end input ): " );
scanf( "%d", &tempCommand );
}
commands[ i ][ 0 ] = 9;
}
My question is what the ",%d" means in:
if ( tempCommand == 5 )
scanf( ",%d", &commands[ i ][ 1 ] );
What I'm trying to say is how does that comma before %d work?
You can actually see from the code below exactly what I mean (type 5,12 in reponse to the first prompt, for example).
#include <stdio.h>
int main()
{
int a,b=0;
scanf("%d",&a);
printf("%d %d\n",a,b);
scanf(",%d",&b);
printf("%d %d",a,b);
}