#include<stdio.h>
#include<string.h>
char *operator[][10] = { {"(",")","[","]","->","."},
};
int main(int argc,int *argv[])
{
int len = sizeof(operator)/sizeof(operator[0][0]);
for( int k = 1 ; k < argc ; k++ )
printf("%s ",argv[k]);
printf("\n");
for( int i = 0 ; i < 2 ; i++ )
{
for( int j = 0 ; j < 6 ; j++ )
{
for( int k = 1 ; k < argc ; k++ )
if( !strcmp( argv[k],operator[i][j]) )
printf("%s",operator[i][j]);
}
}
return 0;
}
after compiled , I want to test if "->" is work,so I use command test.exe ->
,and it turns out a error of syntax.But when I change the command to test.exe "->"
it works. I wonder if it's about order syntax. ps my OS is win7 and I use Dev-cpp. thanks for any help.
>
has special meaning to the command prompt, it's used to redirect output to a file. You need to quote it to treat it literally.
BTW, I think this line in your program is wrong:
int len = sizeof(operator)/sizeof(operator[0][0]);
It should be:
int len = sizeof(operator)/sizeof(operator[0]);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.