fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. char* chooseFileName(void);
  6.  
  7.  
  8. int main()
  9. {
  10. char* file;
  11. file = chooseFileName();
  12. printf("The file '%s' was successfully created\n", file);
  13. free(file);
  14. }
  15.  
  16. char* chooseFileName()
  17. {
  18. char* filename;
  19. char* userInput = calloc(30,sizeof(char));
  20.  
  21. puts("enter the filename:");
  22. scanf("%s", userInput);
  23. printf("Before ass. : %s\n", userInput);
  24. filename = userInput;
  25. printf("After ass. :%s\n", filename);
  26. return filename;
  27. }
  28.  
  29.  
Success #stdin #stdout 0s 2144KB
stdin
Standard input is empty
stdout
enter the filename:
Before ass. : 
After ass. :
The file '' was successfully created