Ok I finally got my program to read in a line as a character array for a string but now I want to convert that character array into an integer array.
Its like this:
if I input 1 2 3 4 5
I want to put that into an integer array with a[0]=1, a[1]=2, etc.
Or if I have this: 12 45 6 23 100
I want to convert that into the integer array like a[0]=12, a[1]=45, a[2]=6, a[3]=23, etc.
If I can do this then my problem is solved so please help me!
I guess I need to find the spaces and concatenate anything before that into an array location such as a[4] or something.
thanks,
dragoon
Here is my code so far!
#include <stdio.h>
int n;
char a[200];
int caten()
{
// int *numchar;
// *numchar = a;
printf("%s", a);
// printf("%d", *numchar);
return 0;
}
int main()
{
n = 0;
printf("Enter some integers (maximum of 20):\n");
while((a[n++]=getchar( )) != '\n' );
a[n] = '\0';
if (a[n] == '\0')
caten();
// printf("%s", a);
return 0;