Guest User

Untitled

a guest
Apr 25th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <fstream>
  5. using namespace std;
  6.  
  7. struct node{
  8. string data;
  9. struct node*next;
  10. };
  11. void insertF (struct node ** head, string a){
  12. node *newNode = new node;
  13. newNode->data = a;
  14. newNode->next = *head;
  15. *head = newNode;
  16. }
  17. void display(struct node *head) {
  18. node *list = head;
  19. while(list) {
  20. cout << list->data << endl;
  21. list = list->next;
  22. }
  23. }
  24. int main(){
  25. string strs;
  26. struct node *head = new node;
  27. ifstream file;
  28. file.open("inputdemolink.txt",ios::in);
  29. getline(file,strs);
  30. insertF(&head,strs);
  31. file.close();
  32. display(head);
  33. return 0;
  34. }
Add Comment
Please, Sign In to add comment