Having some trouble with basic stuff while learning C. might seem foolish, but I hope somone can help me see my mistakes.
my purpose was to flip the pointing order, so it would point to the string from the end to the start. didn't work so well using **str as well.
Code:#include <stdio.h> #include <conio.h> char str_inve(char *ptr); char str_inve(char *ptr) /*a function that is supposed to be pointer - based, and to flip a string, and to return a pointer to the flipped string*/ { char *str; for(;*(ptr+1);ptr++); for (;*ptr;str = ptr, ptr--,str++); /*here is the problem. i can't use *str = *ptr, and this seems to be the only available syntax to use. the str = ptr seems to act like an array, and every time the loop continues the former values erase (*str). */ for(;*(str-1);str--) printf("%c",*(str-1)); return(*str); } void main (void) { int i; str_inve("hello"); scanf("%d",&i); /*irrelevant*/ }