Advertisement
Guest User

QTS no. 1 - How to append a file name onto a file location

a guest
Jun 13th, 2010
842
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.39 KB | None | 0 0
  1. /*
  2. -----------------------------------------
  3. * Game hacking QTS ( Quickie Tip Series )
  4. * no. 1 - How to append a file name onto a file location
  5. -----------------------------------------
  6. * Author: SEGnosis  - GHAnon.net
  7. * Thanks to:
  8. * bitterbanana      - No known site
  9. * Drunken Cheetah   - No known site
  10. * fatboy88      - No known site
  11. * Geek4Ever         - No known site
  12. * learn_more        - www.uc-forum.com
  13. * Novocaine         - http://ilsken.net/blog/?page_id=64
  14. * Philly0494        - No known site
  15. * Roverturbo        - www.uc-forum.com
  16. * SilentKarma       - www.halocoders.com - offline
  17. * Strife        - www.uc-forum.com
  18. * Wieter20      - No known site
  19. */
  20.  
  21. //------------------------------------//
  22. #include <iostream>
  23.  
  24. int main()
  25. {
  26.     char* szFileLocation = "C:\\Foo\\Faa\\Fee.exe"; // Example file location string.
  27.    
  28.     char* dwLetterAddress = strrchr( szFileLocation, '\\' ); // strrchr returns the address of the first instance of the backslash character inside of the szFileLocation string starting from the right side.
  29.  
  30.     *( dwLetterAddress + 1 ) = 0; // De-Referencing the address returned plus the 1 to effect the first letter after the backslash. Setting it to zero ends the string.
  31.  
  32.     strcat( szFileLocation, "MyFileName.txt" ); // Since the string now does not contain the original file name. We can use strcat to append the string we want onto the file location.
  33.  
  34.     return 0;
  35. }
  36. //------------------------------------//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement