Advertisement
paulogp

String: line to column

Jul 13th, 2011
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. /* Hello.World_of.C++
  2.  
  3. Hello
  4. World
  5. of
  6. C++ */
  7.  
  8.  
  9. #include "stdafx.h"
  10. #include <iostream>
  11. #include <windows.h>
  12.  
  13. using namespace std;
  14.  
  15. int _tmain(int argc, _TCHAR* argv[])
  16. {
  17.     // string to be splitted
  18.     char the_string[] = "Hello.World_of.C++";
  19.  
  20.     // seperators
  21.     char the_seperators[] = "._";
  22.  
  23.     // strtok() function returns a pointer to the next "token" in str1,
  24.     // where str2 contains the delimiters that determine the token
  25.     char* the_token = strtok(the_string, the_seperators);
  26.  
  27.     // loop until end
  28.     while(the_token != NULL)
  29.     {
  30.         cout << the_token << endl;
  31.         // tokenize the remaning string
  32.         the_token = strtok(0, the_seperators);
  33.     }
  34.  
  35.     // windows: 5s (windows.h)
  36.     Sleep(5000);
  37.  
  38.     return 0;
  39. }
  40.  
  41.  
  42. // stdafx.h
  43. #pragma once
  44. #include "targetver.h"
  45. #include <stdio.h>
  46. #include <tchar.h>
  47.  
  48.  
  49. // targetver.h
  50. #pragma once
  51. #include <SDKDDKVer.h>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement