So the thing is you have to put in a name, like "wtr".
Then you have to check what's the length of the word.
Now we have to switch the other word, so new_worth have to become : rtw.
But my problem is after the loop to switch the word its still the same as wtr.
I think it must be made with pointers? But can anyone help me?
Code:
#include "stdafx.h"
#include <string.h>
#define AANTAL 8
int _tmain(int argc, _TCHAR* argv[])
{
int i;
int positie = 0;
char word[AANTAL];
char new_word[AANTAL];
int ptr;
printf("Put a word here: ");
scanf("%s",&word);
int length = strlen(word);
strcpy(new_word,word);
printf("%s",new_word);
for(i=length; i>= 0;i--){
scanf("%c",&new_word[i]);
}
//The problem must be here, new_word is still the same as before...
printf("%s",new_word);
//here i wanted to check iff the words are the same or not...
ptr = strcmp(new_word,word);
if(ptr == 0){
printf("They are the same");
}else{
printf("They are not the same");
}
scanf(" ");
return 0;
}