Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I run the following code on Linux:
C++
#include <stdio.h>
#include <string.h>
int main( int argc, char ** argv )
{
    int I_count;
    for( I_count = 0; I_count < argc; I_count++ )
    {
            fputs( argv[I_count], stdout );
    }
    putchar( '\n' );
    return 0;
}

And get this result in terminal window:
Input: ./1 jiawei

Output: ./jiawei

I don't understand why, if you know please answer me. Thanks.

Posted
Updated 25-May-10 0:07am
v3

1 solution

I suppose the program output is actually:
C
./1jiawei

since you didn't put any separator between the printed arguments.
Try
C
...
    for( I_count = 0; I_count < argc; I_count++ )
    {
            fputs( argv[I_count], stdout );
            fputs( " ", stdout);
    }
...


:)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900