Ok all im real lost now. I have an example which i run on the command line (using dev-c++), and when the program is run, the following is displayed:
Two arguments shlould be supplied
C:\Dev-Cpp\projects>
At this point i think the program should enable me to add two arguments, but it does not it expects you to put exe name in again. Can you guys and girls explain in more detail? I have added the code below so you can have a look.
Code:
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
int length, element;
char letter = 'e';
char *chrptr;
if(argc != 3)
{
printf("%s: Two arguments shlould be supplied\n", argv[0]);
return 1;
}
length=strlen(argv[1]);
printf("'%s' contains %d characters\n", argv[1], length);
if((strchr(argv[1], letter))!=NULL)
{
element = strchr(argv[1], letter) - argv[1];
element++;
printf("Letter '%c' is first found at character", letter);
printf(" %d in string '%s'\n", element, argv[1]);
printf("When searching forwards\n");
}
else
printf("Letter '%c' not found in string '%s'\n", letter, argv[1]);
if((strcmp(argv[1], argv[2]))!=0)
printf("String '%s' and '%s' are different\n", argv[1], argv[2]);
else
printf("Strings are identical\n");
return 0;
}