🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c++.leda
Article #109

Help me please...

#109
From: Ki Hong Park
Date: Sat, 30 Sep 1995 22:17
47 lines
1623 bytes
I was trying to write a simple program and ran into a problem that
I didn't know why the compiler was giving error.
I am using AT&T C++ 3.0 compiler and am working on DEC stations
with Unix on it.

Here is my problem.
I have a input file called INPUT which contains some numbers.
ex.  5 10 15 20
The program is suppose to read first input number and create an array
with that length.
ex.  if first input = 5, then length = input and Array[length].

This is what I have.

#include <fstream.h>
int main ()
{
   ifstream input("INPUT"); // the file INPUT contains:  5 10

   int a;
   int b; 

   input >> a;
   input >> b;

   int ArrayA[a];  // line 12
   int ArrayB[b];  // line 13

// and I will have some inputs for those Arrays.

   return 0;
}

When I try to compile this I get an error like this:
% CC test.C  // compile command at the prompt
CC  test.C:
"test.C", line 12: error: cannot evaluate constant
"test.C", line 13: error: cannot evaluate constant
2 errors


What is wrong with this simple program?
What can I do so that I can create arrays with the input from the file?

Please help me and reply to:  khpark@eos.ncsu.edu
Thanks.
Technical Details
Message-ID: <44kfkv$mf5@taco.cc.ncsu.edu>
Path: arc1-ca.pugleaf.net!taco.cc.ncsu.edu!khpark

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!taco.cc.ncsu.edu!khpark
From: khpark@eos.ncsu.edu (Ki Hong Park)
Newsgroups: comp.lang.c++.leda
Subject: Help me please...
Date: 30 Sep 1995 22:17:03 GMT
Organization: North Carolina State University, Project Eos
Distribution: world
Message-ID: <44kfkv$mf5@taco.cc.ncsu.edu>
Reply-To: khpark@eos.ncsu.edu (Ki Hong Park)
NNTP-Posting-Host: c00067-100lez.eos.ncsu.edu
Originator: khpark@c00067-100lez.eos.ncsu.edu