2 Replies - 272 Views - Last Post: 05 October 2012 - 09:59 PM Rate Topic: -----

#1 love2009  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 05-October 12

l am code error

Posted 05 October 2012 - 08:42 PM

#include <iostream>
#include <conio.h>
using namespace std;
//structure declaration;
struct shares
{

string CompanyName;
int Number_of_shares;
double Unit_price_of_shares;
};

//function prototype;
void enterCompanyName (shares shares[]);
void printshares (shares shars[]);

const int sizeOfArray = 50;
int main()
{
shares shares[sizeOfArray];
int amount = i //You will need to ask the user how many they want to




//input the shares;
  for (int i = 0;  i < 0; i++)
  
{
cin >> shares[i].Number_of_shares; // number of shares or unit price
}

//Display totalshares
cout << "The shares entered are: \n"
<< printshares;
_getch();
return 0;
}

//Functions
//Prints out the array of company
void printshares(shares shares[])
{
for(int i = 0; i < i; i++)
{
cout << shares[i].Unit_price_of_shares;
}
cout << endl;

}



this is my code and l am getting an error code c2065 and c2143, can someone tell me what is wrong with the building

This post has been edited by Salem_c: 05 October 2012 - 09:05 PM
Reason for edit:: added [code][/code] tags - learn to use them yourself


Is This A Good Question/Topic? 0
  • +

Replies To: l am code error

#2 Salem_c  Icon User is offline

  • void main'ers are DOOMED
  • member icon

Reputation: 1687
  • View blog
  • Posts: 3,206
  • Joined: 30-May 10

Re: l am code error

Posted 05 October 2012 - 09:11 PM

Well error messages also come with line numbers when the compiler prints them.

The usual thing to do is look at the first error message, then look at that line of code (and perhaps a few lines before it if the error message is about things missing or unexpected), and you figure out what is wrong.

For example.
21 int amount = i //You will need to ask the user how many they want to
What is i?
Where is the ; at the end of the line?

This is easy in an IDE, you normally just double-click on an error message, and it takes you to that line of code.
Was This Post Helpful? 0
  • +
  • -

#3 love2009  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 05-October 12

Re: l am code error

Posted 05 October 2012 - 09:59 PM

thanks l was able to build and debug it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1