Team,
I am trying to read the string from user and the allocate it to the another string which is ptr string but not successful, so not sure what am I missing here.
Do I have to use any dynamic memory allocation here?
Code:int main(){ char test[5]; char *strng, *base; int i; base=strng; for(i=0; i<4; i++){ printf("Enter the value of element %d: ",i); scanf("%s",test); strng=test; <<<<<< is this valid? strng++; <<< want to store value of test to strng and then move strng to next block so I can store new value. } //Following is to print the value that I stored from test to strng. strng= base; for(i=0; i<4; i++){ printf("value of strng is %s\n", strng); strng++; } }
It will be great if you can point me to any reference or doc to read about it.