Hi all. Im trying something new. Something yesterday gave me an idea that i could use it with more than one source file. So i created 2 source files and 1 header file to do all the including and bridging communication between sources.
Here's what i have so far.
Source 1
#include "include.h"
int main(){
const SIZE = 100;
char msg[SIZE];
printf("Enter a file you'd like to read: ");
cin.getline(msg,SIZE);
if(!msg){
printf("File %s doesnt exist.\n",msg);
}
else{
printf("Reading file %s",msg);
readfile();
}
return 0;
}
Source 2
#include "include.h"
void readfile(void){
char buffer[100]={'\0'};
ifstream file("test.txt");
while(file.getline(buffer, 100)){
Sleep(3000);
printf("%s\n",buffer);
}
file.close();
cin.get();
}
Source 1 is to check what type of file you want to read. And determines if its in the area or not. Then source 2 actually does the reading once source1 gives it the O.K. - But im getting errors like mad.
: error C2513: 'const struct tagSIZE' : no variable declared before '='
: error C2275: 'SIZE' : illegal use of this type as an expression
: see declaration of 'SIZE'
: error C2057: expected constant expression
: error C2466: cannot allocate an array of constant size
: error C2133: 'msg' : unknown size
: error C2275: 'SIZE' : illegal use of this type as an expression
: see declaration of 'SIZE'
If i compile them individually they work fine. But together they seem not to like each other. How do i fix this Thanx in advance.

Trying something new
SOTY_Programmer
please refer this link also.
Managed Code in Visual Studio 2005
In earlier versions of Visual Studio, it was possible to declare like you specified. now it has changed. Seems your code still will work in VC++ 6.0.
Richie Thorpe
What's SIZE Do you mean "const int SIZE"
mranzani
I am going to mark this thread as answered since you have not followed up with any further information on your problem as requested for over a week - I assume you solved the problem yourself or one of the suggestions in this thread helped you solved the problem. If you have a solution you could post it so others can find it. If you do not have a solution then please submit further details and then mark the thread as unanswered.
thank
bite
E. Ward
It complied with no error in my machine after change const SIZE = 100; to const int SIZE = 100;
Compiler will not inject int as the default type in declarations
Code that is missing the type in a declaration will no longer default to type int the compiler will generate Compiler Warning C4430 or Compiler Warning (level 4) C4431. Standard C++ does not support a default int and this change will ensure that you get the type you really want.
see: http://msdn2.microsoft.com/en-us/library/ms177253.aspx
thanks
bite