Aman Agarwal

Aman Agarwal

  • NA
  • 1
  • 700

convert from c++ to c# code

Sep 14 2016 3:39 PM
#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++;
}
}
}

Answers (2)