- #1
chaoseverlasting
- 1,050
- 3
Im having a problem with a cpp program. It gives me 6 linker errors, which have something to do with buffer overflows. I used borland turbo cpp 3 to compile this. What should I do. Here's the code:
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
ofstream write;
ifstream read;
int i;
void main()
{
fflush(stdin);
write.open("c:\windows\test.txt"); //open file for output
char put1[80], get1[80];
cout<<"Enter a sentence (<80): ";
cin>>put1;
for(i=0;i<80;i++)
write.put(put1);
write.put('\n');
write.close();
read.open("c:\windows\test.txt", ios::in);
if(!read)
{
cout<<"File cannot be opened";
}
read.seekg(0);
while(!read.eof())
{
read.getline(get1,80,'\n');
cout<<get1<<"\n";
}
read.close();
}
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
ofstream write;
ifstream read;
int i;
void main()
{
fflush(stdin);
write.open("c:\windows\test.txt"); //open file for output
char put1[80], get1[80];
cout<<"Enter a sentence (<80): ";
cin>>put1;
for(i=0;i<80;i++)
write.put(put1);
write.put('\n');
write.close();
read.open("c:\windows\test.txt", ios::in);
if(!read)
{
cout<<"File cannot be opened";
}
read.seekg(0);
while(!read.eof())
{
read.getline(get1,80,'\n');
cout<<get1<<"\n";
}
read.close();
}