Tech
Forums
Jobs
Books
Events
Live
Interviews
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
2
Reply
convert from c++ to c# code
Aman Agarwal
Sep 14 2016 3:39 PM
254
Reply
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
using namespace std;
struct node
{
string stock_code;
string stock_name;
double amt_invested;
int shares_held;
double current_price;
struct node *next;
struct node *prev;
};
int main()
{
ifstream infile("input.txt");
string sc,sn;
double ai,cp;
int sh;
int flag = 0;
struct node* head1 = NULL;
struct node* head2 = NULL;
while (infile >> sc >> sn >> ai >> sh >> cp)
{
// cout << sc << " " << sn << " " << ai << " " << sh << " " << cp << endl;
if(flag == 0)
{
struct node* temp = (struct node*)malloc(sizeof(struct node));
temp->stock_code = sc;
temp->stock_name = sn;
temp->amt_invested = ai;
temp->shares_held = sh;
temp->current_price = cp;
//cout << "ho" << endl;
temp->prev = NULL;
temp->next = NULL;
head1 = temp;
temp = (struct node*)malloc(sizeof(struct node));
temp->stock_code = sc;
temp->stock_name = sn;
temp->amt_invested = ai;
temp->shares_held = sh;
temp->current_price = cp;
temp->prev = NULL;
temp->next = NULL;
head2 = temp;
flag++;
}
temp->prev = NULL;
temp->next = NULL;
head1 = temp;
temp = (struct node*)malloc(sizeof(struct node));
temp->stock_code = sc;
temp->stock_name = sn;
temp->amt_invested = ai;
temp->shares_held = sh;
temp->current_price = cp;
temp->prev = NULL;
temp->next = NULL;
head2 = temp;
flag++;
}
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
create a List of list
how to convert object to json and json to object?