Advertisement
constantin-net

leh2

Dec 5th, 2011
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <stdlib.h>
  4. #include <cstring>
  5. #define SIZE 10
  6. using namespace std;
  7.  
  8. struct rlink
  9. {
  10. char data[SIZE];
  11. rlink* next;
  12. };
  13.  
  14. class St
  15. {
  16. private:
  17. char* str1,* sp;
  18. rlink* first;
  19. int l1, l2;
  20. public:
  21. St(char* s1)
  22. {
  23. first=NULL;
  24. l1=strlen(s1); //l2=strlen(s2);
  25. str1 = new char[l1+1];
  26. //str2 = new char[l2+1];
  27. strcpy(str1,s1); //strcpy(str2,s2);
  28. }
  29.  
  30. void fun()
  31. {
  32. for(int n=0, m=0;m<strlen(str1);m++)
  33. {
  34. if(str1[m]!=' ')
  35. {sp[n]=str1[m]; n++;
  36. cout << &str1 <<' '<<&sp<< endl;
  37. }
  38. else
  39. {
  40. sp[n]='\0';
  41. rlink* newlink = new rlink;
  42. strcpy(newlink->data,sp);
  43. newlink->next = first;
  44. first = newlink;
  45. //cout << newlink->next << endl;
  46. n=0;
  47.  
  48. }
  49. }
  50.  
  51. return;
  52. }
  53.  
  54. void disp()
  55. {
  56. rlink* cur = first;
  57. while(cur!=NULL)
  58. {
  59. cout << cur->data << ' ' << cur->next << endl;
  60. cur=cur->next;
  61. }
  62. return;
  63. }
  64. ~St()
  65. {
  66. delete []str1;
  67. cout << "deleted1\n";
  68. //cout << "deleted2\n";
  69. //delete []str2;
  70. }
  71. };
  72.  
  73.  
  74. int main()
  75. {
  76. char di[100];
  77. //char di2[100];
  78. cin.getline(di, sizeof(di));
  79. //cin.getline(di2, sizeof(di2));
  80.  
  81. St list(di);
  82. list.fun();
  83. list.disp();
  84.  
  85. return 0;
  86. }
  87.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement