Advertisement
toribio

Untitled

Sep 18th, 2012
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <shlobj.h>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6.     const char *szFileName = "text.txt";
  7.     const char *szContent = "test string";
  8.    
  9.     char szPath[_MAX_PATH];
  10.    
  11.     SHGetSpecialFolderPath(NULL, szPath, CSIDL_DESKTOPDIRECTORY, FALSE);
  12.    
  13.     strcat(szPath, "\\");
  14.     strcat(szPath, szFileName);
  15.    
  16.     FILE *pFile = fopen(szPath, "a+");
  17.    
  18.     if(pFile != NULL)
  19.     {
  20.         fputs(szContent, pFile);
  21.         fclose(pFile);
  22.     }
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement