Lost Password?

  #1 (permalink)  
Old 04-24-2008, 12:26 PM
ISmajor ISmajor is offline
Newbie
 
Join Date: Apr 2008
Posts: 1
Rep Power: 0
ISmajor is on a distinguished road
Default help with arrays...

i am trying to write a program with two arrays...

my code::
Code:
// project5.cpp : main project file.

#include "stdafx.h"

using namespace System;

int main(array<System::String ^> ^args)
{
double hours __gc[] = new double __gc[10];
double charges __gc[] = new double __gc[10];
double total;

do
Console::WriteLine( L"Enter the number of hours parked:" );
hours[i] = Double::Parse( Console::ReadLine() );
if hours[i] > 24
Console::WriteLine( L"Maximum number of hours has been exceeded");
while hours[i] > 24

if hours[i] <= 2
charges[i] = 5
else
charges[i] = ((hours - 2) * .5) + 5;

if hours[i] > 10
charges[i] = 10;

Console::WriteLine( L"Car Number:\tHoursParked:\tAmount Charged:");

for (double i = 1, i <= 10, i++)
Console::WriteLine( L "{0}\t\t{1}\t\t{2}", i.ToString(), hours[i].ToString(), charges[i].ToString() );

for (int i = 0; i<charges-> Length; i++)
total += charges[i];

Console::WriteLine( L"Total Charges from Yesterday: {0}", total.ToString() );

return 0;
}

ERRORS:
.\project5.cpp(9) : error C4980: '__gc' : use of this keyword requires /clrldSyntax command line option
.\project5.cpp(9) : error C2440: 'initializing' : cannot convert from 'double *' to 'double []'
There are no conversions to array types, although there are conversions to references or pointers to arrays
.\project5.cpp(10) : error C2440: 'initializing' : cannot convert from 'double *' to 'double []'
There are no conversions to array types, although there are conversions to references or pointers to arrays
.\project5.cpp(15) : error C2061: syntax error : identifier 'hours'
.\project5.cpp(16) : error C2061: syntax error : identifier 'hours'
.\project5.cpp(18) : error C2061: syntax error : identifier 'hours'
.\project5.cpp(25) : error C2061: syntax error : identifier 'hours'
.\project5.cpp(30) : error C2143: syntax error : missing ',' before '<='
.\project5.cpp(30) : error C2086: 'double i' : redefinition
.\project5.cpp(30) : see declaration of 'i'
.\project5.cpp(33) : error C2227: left of '->Length' must point to class/struct/union/generic type
type is 'double []'
Edit/Delete Message

Last edited by WingedPanther; 05-04-2008 at 07:08 PM. Reason: add code tags
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 05-03-2008, 10:46 AM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 2,969
Last Blog:
Piano Exam
Rep Power: 25
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: help with arrays...

These are compile errors, which effectively means there are mistakes in the code. Double-check to see if you've made any mistakes.
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 05-04-2008, 07:16 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Mod
 
Join Date: Jul 2006
Age: 35
Posts: 1,751
Last Blog:
Game software (GURPS)
Rep Power: 24
WingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to allWingedPanther is a name known to all
Default Re: help with arrays...

It looks like __gc is not defined in the current scope.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 05-04-2008, 11:43 PM
v0id's Avatar   
v0id v0id is offline
Super Mod
 
Join Date: Apr 2007
Location: Denmark
Posts: 1,876
Last Blog:
CherryPy(thon)
Rep Power: 23
v0id is a name known to allv0id is a name known to allv0id is a name known to allv0id is a name known to allv0id is a name known to allv0id is a name known to all
Send a message via MSN to v0id
Default Re: help with arrays...

Quote:
.\project5.cpp(9) : error C4980: '__gc' : use of this keyword requires /clrldSyntax command line option
Did you try doing like the message suggests? Try compiling with /clrldSyntax.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 05-06-2008, 07:03 AM
Xav's Avatar   
Xav Xav is offline
Guru
 
Join Date: Mar 2008
Location: London, England
Posts: 2,969
Last Blog:
Piano Exam
Rep Power: 25
Xav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to allXav is a name known to all
Send a message via MSN to Xav
Default Re: help with arrays...

Try moving __gc to a module-level location, or even public.
__________________
Xav, the power of youth
Worship the Creator... not his creations
Web Site | Beta Site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #6 (permalink)  
Old 07-02-2008, 11:33 PM
the ftb the ftb is offline
Newbie
 
Join Date: Jul 2008
Posts: 2
Rep Power: 0
the ftb is on a distinguished road
Default Re: help with arrays...

yaaa fur sure there is mistakes in the codes ...... it happend to me once but i fixed it by a programmer who is travelling all over the world finding helpless poeple who cannot solve errors like meee ..... thanx
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-02-2008, 11:57 PM
Aereshaa's Avatar   
Aereshaa Aereshaa is offline
Learning Programmer
 
Join Date: Apr 2008
Posts: 52
Rep Power: 1
Aereshaa will become famous soon enough
Default Re: help with arrays...

Okay, first, it looks like you are trying to use "hours" and "charges" as types.
Code:
double hours __gc[] = new double __gc[10];
double charges __gc[] = new double __gc[10];
So, it looks like you are defining "__gc" twice, once as the (as far as I know) nonexistant type "array of double hours", and another time as "array of double charges". Later, you refer to these as "hours[]" and "charges[]". Therefore, change your bad declarations to these:
Code:
double hours[] = new double [10];
double charges[] = new double [10];
Next, if statements require () around their condition.
Code:
if hours[i] <= 2
should be
Code:
if(hours[i] <= 2)
Code:
do
Console::WriteLine( L"Enter the number of hours parked:" );
hours[i] = Double::Parse( Console::ReadLine() );
if hours[i] > 24
Console::WriteLine( L"Maximum number of hours has been exceeded");
while hours[i] > 24
Here, you tried to make a do/if statement which don't exist (at least in C).

Another error is here:
Code:
charges[i] = ((hours - 2) * .5) + 5;
You refer to "hours" which is the address of the first element of the array hours. This should be changed to "hours[0]", "hours[i]", or whatever element of the array hours[] you mean.

All in all, it looks like you're using Perl syntax in C++, so... learn C++!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Arrays Fedex C and C++ 3 12-02-2007 04:45 PM
Python arrays... Sir_Rimo Delphi/Python 3 06-20-2007 08:54 AM
Arrays clookid PHP Tutorials 1 01-11-2007 08:30 PM
Arrays Sionofdarkness C and C++ 5 07-26-2006 05:35 PM
Arrays in NET 2.0 or CLI Managed C++ Void Managed C++ 1 07-18-2006 07:57 PM


All times are GMT -5. The time now is 10:53 PM.

Contest Stats

John ........ 87.50000
dargueta ........ 75.00000
Xav ........ 50.00000
MeTh0Dz ........ 20.00000
gaylo565 ........ 18.00000
Johnnyboy ........ 3.00000

Contest Rules

Ads