My code is working fine when I compile with dev-c++, but when I use Windows Visual C++ it comes up with the following error messages. The problem is I don't know what my professor uses. Any advice?
1>c:\users\jacob\documents\cis\prgm3.cpp(10) : warning C4267: '=' : conversion from 'size_t' to 'int', possible loss of data
1>c:\users\jacob\documents\cis\prgm3.cpp(11) : error C2057: expected constant expression
1>c:\users\jacob\documents\cis\prgm3.cpp(11) : error C2466: cannot allocate an array of constant size 0
1>c:\users\jacob\documents\cis\prgm3.cpp(11) : error C2133: 'stringAsArray' : unknown size
I don't know why dev allows this, but it's not correct programming. And you should update to wxdev.
First of all, you can't just define an array from a variable. That's the problem with "expected constant expression". The solution is to allocate dynamically. If you don't know how, read the tutorial on this website; it has a section on dynamic allocation.
The next thing is the same thing, really. It has to prepare for the contingency that you have an empty string, since you've allocated the array statically - its size is determined at compile time. Since the string might be empty, the size might be zero. That is not allowed. The last one is also the same - you need to know the size. It must be constant to allocate an array statically.
The problem is I'm now getting the errors:
1>ifstatement.obj : error LNK2005: _main already defined in array.obj
1>prgm3.obj : error LNK2005: _main already defined in array.obj
1>Debug\prgm3.exe : fatal error LNK1169: one or more multiply defined symbols found