|
-
Aug 30th, 2002, 01:23 PM
#1
Thread Starter
Ya ya Baby!!!Me is Back
Array declaration problem
Code:
const usi iSize= SizeOfMyFile(File);
char sFile[iSize];
Error :
1-Expected constant expression
2-cannot allocate an array of constant size 0
3-unknows size
-
Aug 30th, 2002, 01:31 PM
#2
Frenzied Member
In visual basic you cant declare Consts with arguments
cause it has no preprocessor.
Is that still true in C++?
-
Aug 30th, 2002, 05:01 PM
#3
Frenzied Member
Evan is right. You have to use some immediate value that the compiler can resolve. Not something that arises only during run-time.
-
Aug 30th, 2002, 09:34 PM
#4
Thread Starter
Ya ya Baby!!!Me is Back
-
Sep 2nd, 2002, 04:50 AM
#5
You have to use new if you want to have an array of dynamic or runtime-determined size.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 2nd, 2002, 09:47 AM
#6
Thread Starter
Ya ya Baby!!!Me is Back
Tell me if that good :
Code:
const usi iSize= SizeOfMyFile(File);
char sFile = new char[iSize];
-
Sep 2nd, 2002, 10:45 AM
#7
if the first line is inside a function it's ok, else remove the const.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 2nd, 2002, 02:00 PM
#8
Thread Starter
Ya ya Baby!!!Me is Back
ok thank you
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|