C really isn't my strong point and after reading 3 chapters of a book on the subject and spending ages trying to get stuff working it just doesn't:
#include <stdio.h>
char *a,*b;
int main( )
{
char input[10];
fgets(input,sizeof input, stdin);
a = input;
fgets(input,sizeof input, stdin);
b = input;
printf("%s : %s",a,b);
}
I've isolated the problem from my main project. This code is meant to read in two strings and then print them however it seems to be setting a and b to point to input. Sample output from this code when A and B are entered is(don't worry about the \n's i can remove them):
A
B
B
: B
How do i store the value of input in another variable eg. a or b so that in the above case
A
B
A
: B
Is output?
NOTE: I don't want a or b to point to another variable i want to store a string in them:
a = "A";
b = "B";
would be the string literal equivalent.
Thanks