grrrrrrr dam...i hate c++

heat23

Elite Member
Oct 9, 1999
3,998
9
81
www.heatware.com
im using visual studio..im tryin to compile some code that the teacher gave....i keep getting this error..

fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe.

now its sayin that for code that i wrote that used to work before...

heres my includes:

#include "iostream.h"
#include "stdlib.h"
#include "string.h"
#include "stdio.h"


anyone know whats wrong??
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
The FIRST include should be:

#include "stdafx.h"


Are you building a Win32 program or a console program? If it's the latter, then the error should not come up. If not then are you sure you selected the right kind of project?
 

heat23

Elite Member
Oct 9, 1999
3,998
9
81
www.heatware.com
nope still get the error...
all this worked like 20 minutes ago...but now it doesnt..
i tried closing the program and reopening..same result...
even tried creating new projects
 

worth

Platinum Member
Feb 4, 2001
2,369
0
0
It's not "iostream.h" it's <iostream.h>. You're including library files.
 

heat23

Elite Member
Oct 9, 1999
3,998
9
81
www.heatware.com
I get 21 errors when i try to compile this...anyone wanna take a stab at it (this is the TA's solution...so i assume it works)
NOTE: I added the #include "stdafx.h" part myself


#include "stdafx.h"
#include <iostream.h>
#include <string.h>


void main()
{
string words[20], temp;
int ii=0, flag, wordcount;
cout<<"Enter the words"<<endl;
do{ ii++;
cin>>words[ii]; } while(words[ii]!="quit");
wordcount = ii-1;
for(ii=0; ii<wordcount; ii++)
{
for(int j=ii+1; j<=wordcount; j++)
{
if(words[j]<words[ii]){
temp=words[j];
words[j]=words[ii];
words[ii]=temp;
}
}
}
cout<<"input after repeating repition and sorting"<<endl;
for(int j=0; j<=ii; j++){
flag = 0;
int k =0;
while(k<j && flag ==0){
flag = (words[j]==words[k]);
k++;
}
if(flag==0)
cout<<words[j]<<" ";
}
cout<<endl;
}
 

johnjohn320

Diamond Member
Jan 9, 2001
7,572
2
76
I hate to be a jerk, but seriously guys, there's a PROGRAMMING FORUM. Please post C++ questions there. Please? Pretty please?
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
This will get you down to two errors:

(1) Delete #include "stdafx.h" -- not needed
(2) Delete #include <string.h> and put this in its place:

#include <string>
using namespace std;


Compile... down to two errors. You can eliminate them with some coding.
 

MonstaThrilla

Golden Member
Sep 16, 2000
1,652
0
0
Whats the stadfx.h for? Also, void main() is a no-no. Use int main() and return a 0 before the last curly. Also, you really don't need .h and you should say "using namespace std" after the includes. How old is the book your using? Pretty old I'd guess?

What are you trying to do in your program? And format the curlies so its more readable please.

What type of errors are you getting?

And C++ DOES NOT suck, be grateful your learning it instead of some sh!t like Scheme that I'm being FORCED to learn now...
 

heat23

Elite Member
Oct 9, 1999
3,998
9
81
www.heatware.com
hey thanks...

rror C2679: binary '>>' : no operator defined which takes a right-hand operand of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
(or there is no acceptable conversion)


wtf does that mean...ha



BTW: If i take out stdafx.h, i get this error fatal error C1010: unexpected end of file while looking for precompiled header directive
Error executing cl.exe........so i think i have to keep it
 

Platypus

Lifer
Apr 26, 2001
31,046
321
136
Ahh that is the sloppiest code I have ever seen man :(
First of all follow the advice about <iostream.h> instead of "iostream.h"
Secondly, comment your damn code
Thirdly, NEVER use void for your main function
Lastly, dont forget your last curly brace to solve the error..
 

joohang

Lifer
Oct 22, 2000
12,340
1
0


<< And C++ DOES NOT suck, be grateful your learning it instead of some sh!t like Scheme that I'm being FORCED to learn now... >>


LMAO!

Oh.. I was so grateful that I was not in CS when I saw my friends taking a Scheme course. What a waste of time.
 

bleeb

Lifer
Feb 3, 2000
10,868
0
0
For all standard header files... use the < > as brackets. For example: #include <stdio.h>.

For all user defined header files... use the quotes. For example: #include "myheaderfile.h"

Get it? Got it?? Good.
 

GT578

Senior member
Feb 7, 2000
721
0
0
SCHEME fu*king sucks........I had to deal with that crap all summer. I enjoyed learning C++ much more.....
 

singh

Golden Member
Jul 5, 2001
1,449
0
0
This should compile & run...

#include "stdafx.h"
#include <iostream.h>
#include <string.h>
#include <string>
using namespace std;


void main()
{
char strtemp[256];
string words[20], temp;
int ii=0, flag, wordcount;
cout<<"Enter the words"<<endl;
do{ ii++;
cin >> strtemp;
words[ii] = strtemp;
} while(words[ii]!="quit");
wordcount = ii-1;
for(ii=0; ii<wordcount; ii++)
{
for(int j=ii+1; j<=wordcount; j++)
{
if(words[j]<words[ii]){
temp=words[j];
words[j]=words[ii];
words[ii]=temp;
}
}
}
cout<<"input after repeating repition and sorting"<<endl;
for(int j=0; j<=ii; j++){
flag = 0;
int k =0;
while(k<j && flag ==0){
flag = (words[j]==words[k]);
k++;
}
if(flag==0)
{
cout << words[j].data() << " ";

}
}
cout<<endl;
}