开发者

How can I add command line arguments when compiling and running a C program in Xcode?

When I work on C currently, I use Xcode and just press Build & Run in the Debugger Console which shows all the program's output.

How can I add command line arguments when compiling and running a C program in Xcode?

I want to test iterating through command line arguments now. I tried to fake it with...

int main() {    
    char *argv[] = {"echo","-n","hello world!"};
    int argc = 3;
}

But trying to iterate through argv kept giving me an error...

error: lvalue required as increment operand

When I tried to ++argv.

So, I'm wondering, how can I give some command line arguments to my program when I run it this way, or do I nee开发者_如何学编程d to compile and then run it with Terminal?

Thanks!


Go to Project -> Edit Active Executable and add your arguments on the Arguments tab.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜