D
david
Code:
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
int main (int argc, char const *argv[])
{
if (argc == 1)
printf("No parameters! Use --help to get more information.");
if (argc == 2 && argv[1] == "--help")
printf("Just test, you are free now.");
if (argv[1][0] == "-")
printf("This does not work?");
return 0;
}
Two questions:
1) How can I compare parameters to string, maybe I should use sprintf
and later try comparing? Or maybe there is direct way of doing it?
2) How can I get first char of the first parameter? (It's kinda hard
to understand how to write this)
Using gcc 4 version under Mac OS X.
#include <stdio.h>
#include <strings.h>
#include <stdlib.h>
int main (int argc, char const *argv[])
{
if (argc == 1)
printf("No parameters! Use --help to get more information.");
if (argc == 2 && argv[1] == "--help")
printf("Just test, you are free now.");
if (argv[1][0] == "-")
printf("This does not work?");
return 0;
}
Two questions:
1) How can I compare parameters to string, maybe I should use sprintf
and later try comparing? Or maybe there is direct way of doing it?
2) How can I get first char of the first parameter? (It's kinda hard
to understand how to write this)
Using gcc 4 version under Mac OS X.