I am trying to parse main(argc, argv[]); and i need to look at individual
characters with in the strings pointed to by *argv[]. I though of a string
as an array of chars. This builds fine but causes an error in execution.
So what is a simple and straight forward way. Lets say I want to look at
each character in a string pointed to by argv[c] and/or compare the each
character or compare strings.
I am sure this is quite simple and I want to keep it simple if possible.
I am missing something here. Thanks in advance for suggestions.
// ArgParse.cpp : Defines the entry point for the console application.
// How can you refer to a character in a string? This does not work !!!
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
int c = argc;
while (c) {
printf("arg %i - |%s|\n",c,argv[c]);
if (argv[c][0] == '-') { // Look at char in pos 0 ='-'? //
printf("|%c|\n", argv[c][1]); // then show what it is //
}
c--;
}
-eof-
73
-Grace
NNNN
z