The function takes a string pointer and returns by refrence a string . I can print the string just fine in the function inself but when i try to print it from the main function it prints some junk. Can any body tell me why?? Pleaseeeeeeeeeeeeeeeeeeeeeeeeeeeeee
Code:int validateInptFile(char *fPtr, char **seqNo){ char fileName[18], sNo[10]; strncpy(sNo, &fileName[9], 4); sNo[4] = '\0'; *seqNo = &sNo[0]; printf("seqNo > %s\n", *seqNo); //output "0001" } //function call from main validateInptFile(newAddFile, &curSeqNo)); printf("MAIN > %s\n", curSeqNo); //outputs some junk