arguments ...

maccatalan

Registered
Hi.

I'm trying to make a Cocoa appl. A good point : since now it worked! The dark point: I would like the computer to play. (It's a game) But I would like to do it to use a second program thanks the NSPipe, in order to split the CPU "brain" from the GUI. I made the program wich tells having the game configuration what to play for the CPU in C++.
It's an Awale game but maybe you don't know what Awale is so imagine a program that computes the sum of the arguments. (my game description for the arguments will be numerical)

So that I would like to do is :
a "pure" C++ program, with as arguments the numerical description of the cells of the game, and as return the coordonates of the cell to play.

example, "sum 0 0 2 0 3 0 1 10 18 2" would return "36".

My problem is to get the arguments ... well to get them as numbers.

If you know an easy way to put the arguments in an array on Darwin/OS X, thank you for answering me. :)

NB: <getopt.h> doesn't seem to exist with the Apple DevTools ... :(
NB: If you know a way to do it using NSStrings thank you, that's good to learn, but I better like (maybe I'm too much demanding) a "pure" C++ program in order to port it to Windows (sorry ... :D)

Thank you,
Pierre.
 
Ok ... I was tired the day I posted this Topic : my english was unfathomable and the solution was very easy. So here I post this solution, thanks to it you won't learn anything, but you will maybe understand the meaning of my first long and uncomprehensible message. :rolleyes:

//--------------------------------------------------begin, lang:C++
#include <iostream>
#include <stdlib.h>

int main(int argc, char *argv[])
{
for (int i=1; i<argc; i++)
std::cout << argv << "-1 = "<< strtol(argv, NULL, 10)-1 << '\n';

return 0;
}
//--------------------------------------------------end

Have fun,
Pierre.
 
Back
Top