I was told to remake this with proper comments and the actually code I'm working on. I'm attempting to take a command line input and put it into an array. I want to then parse this array into two new arrays.
The problems are argv[1] is a char * so I'm running into problems converting into an INT. I also can't figure out how to take each element from argv[1], (e.g. 1010101) and place those 1's and 0's into an array. Once I figure this out, I'm going to take this array and parse it if the input is greater than 5. The command line argument coming in is going to be either 5 length or 10 length. If its 5 I do nothing, if its 10 I parse the input into two arrays.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char * argv[]) {
int i;
//starting using char * arrays in order to try to grab input from the char * argv[1] command line arg
char *aA[10] = {0};
char *aB[10] = {0};
char *aC[10] = {0};
char *s = '1';
char *k = '0';
//read in from command the command line. Print the arguments and save
//the 1 and 0 inputs into an array.
//need to check for EOF and next lines
for (i = 0; i < argc; i++)
{
if (argv[i] == (s | k)) //attempting to find a way to look at 1 and 0 as a char
{
aA[i] = argv[i]; //place the 1 or 0 into array aA
}
printf("arg %d: %s\n", i, argv[i]);
}
printf("\n");
//print array aA to see if it caught all of the 1's and 0's from the command line argument
for (i = 0; i < 8; i++)
{
printf("%s ", aA[i]);
}
//next check if array aA is 5 strlen or 10 strlen
//if 5, do nothing
//if 10, parse array aA into two arrays aB and aC
//aB gets a[0] a[2] a[4] a[6] a[8]
//aC gets a[1] a[3] a[5] a[7] a[9]
//print the results of aB and aC to make sure aA was correctly parsed
printf("\n");
return 0;
}
1000110001is a combination of two numbers?