This is doing my head in and I have been at it for hours. I have googled with no luck. tried different loops again no joy.
I have done what I need to do however without using an array, its messy and its limited, now I am improving my code by using an array.
The code is meant to assign the first character after a space to an array. The program runs fine providing there are no spaces.. HA. If there is a space I get "Segmentation fault (core dumped)
So in turn given I get the above error when I input a space I am 99% sure the problem is in the code below. But I can not figure it out.
I will post the whole code if required but I didn't want to waste anyones time.
Code:for (int i = 0; i < strlen(input); i++) { if (input[i] == 32) // Checking if a space is present. { count++; // Counting spaces from input to use later. *argv[x] = input[i + 1]; // assigning the char after space to an array. x++; argc++; } }
Thanks in advance.