Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Code a program which gets user data from csv file and then show it to us.
- Saving of each data will be taken in link list as storage data
- Program Coded For BS-CS 2nd Semester - UOS
- by Ñasir Ali
- For more Coding and tricky stuff visit :
- www.tigerzplace.com
- www.softwarezcity.ml
- www.thenavrock.com
- For Video tutorials Jump here :
- www.youtube.com/user/t1g3r6117
- Thanks :)
- */
- // Download this coded program @ : https://www.mediafire.com/?csux1snqbavxcya
- #include <iostream> //will be use for cout and cin objects
- #include <fstream> //for using the input file function
- #include <string> //included here to use getline function later on
- #include <conio.h> //to use the getch() function so after creating exe file it catches the screen for us :)
- using namespace std;
- struct node{
- string data;
- node *link;
- };
- int main()
- {
- int r;
- string d,a,age,g;
- node *start=NULL,*cur,*temp; //we will keep address of node members , that's why I choose node data type pointers
- ifstream file ( "database.csv" ); //this line opens the file mentioned here
- if(!file){
- cout << "'Database.csv' not found !!!!";
- }
- while (!file.eof())
- {
- getline(file,d); //this will grab the whole first line from databasae.csv file
- if(start==NULL){
- start=new node;
- start->data=d;
- start->link=NULL;
- }
- else{
- cur=start;
- //this while loop will go to the end
- while(cur->link!=NULL){
- cur=cur->link;
- }
- temp=new node;
- temp->data=d;
- cur->link=temp;
- temp->link=NULL;
- }
- }//All Data is Picked from Database.csv
- //Printing Starts here
- cur=start;
- cout << "\t\t\tStudents Record \n\n\n";
- cout<<"Roll#, Name, Gender, Age, Address\n\n";
- while(cur->link!=NULL){
- cout<< cur->data <<endl;
- cur=cur->link; //Incrementing in the address pointing
- }
- file.close();
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement