Ok, whenever i do any C i always seem to get stuck at this point:
I want to return a char array from a function to be used in main, like so:
By my knowledge, this should work fine, but for some reason or other fails miserably, printing out the edited strings either results in strings of rubbish or nothing at all!Code:char *editString(char *someString, char *someOtherString){ int i = 6; someString = (char*) malloc(i+1); someString = "hello"; someOtherString = (char*) malloc(i+1); someOtherString = "byeee"; } int main (){ char *someString, *someOtherString; editString(someString, someOtherString); printf("%s - %s\n", someString, someOtherString); }
heeeelp!



LinkBack URL
About LinkBacks



