home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_11_08 / hellquis / teststr.cpp < prev    next >
C/C++ Source or Header  |  1993-01-23  |  978b  |  44 lines

  1. //teststr.cpp  -- simple test routine for GetPrivateProfileString
  2. #include "profiles.h"
  3. #include <string.h>
  4. #include <iostream.h>
  5.  
  6.  
  7. void main()
  8. {
  9.     char app[81];
  10.     char key[81];
  11.     char out[600];
  12.     char *s ;
  13.     int no ;
  14. //-- part one , test getting all keys for an application
  15.     cout << "This test uses file test.ini\n";
  16.     cout << "Application -> all keys :" ;
  17.     cin.get(app,sizeof(app));
  18.     cin.ignore();
  19.  
  20.     no = GetPrivateProfileString
  21.         (app,NULL,NULL,out,600,"test.ini");
  22.     cout << "no : " << no << "\n";
  23.     s = out ;
  24.     while (*s)
  25.     {
  26.         cout << " str : " << s << "\n" ;
  27.         s +=strlen(s)+1;
  28.     }
  29. //-- part two, repeatedly test getting a specific key
  30.     for (;;)
  31.     {
  32.         cout << "Application :";
  33.         cin.get(app,sizeof(app));
  34.         cin.ignore();
  35.         cout << "Key :";
  36.         cin.get(key,sizeof(key)) ;
  37.         cin.ignore();
  38.         no = GetPrivateProfileString
  39.         (app,key,"Default",out,81,"test.ini");
  40.         cout << "no : " << no << " str : " << out << "\n" ;
  41.     }
  42. }
  43.  
  44. //-- end of teststr.cpp