Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <fstream>
- using namespace std;
- struct node{
- string data;
- struct node*next;
- };
- void insertF (struct node ** head, string a){
- node *newNode = new node;
- newNode->data = a;
- newNode->next = *head;
- *head = newNode;
- }
- void display(struct node *head) {
- node *list = head;
- while(list) {
- cout << list->data << endl;
- list = list->next;
- }
- }
- int main(){
- string strs;
- struct node *head = new node;
- ifstream file;
- file.open("inputdemolink.txt",ios::in);
- getline(file,strs);
- insertF(&head,strs);
- file.close();
- display(head);
- return 0;
- }
Add Comment
Please, Sign In to add comment