grrrrrrr dam...i hate c++

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.

Blackened

Member
Oct 24, 2000
166
0
0
This would be flamebait on a c++ board. You have A TON OF non-standard
headers and errors in your code.

WTF? DO NOT USE VOID MAIN()!!!!!!!!!!

christ, its int main()

and iostream.h is a nonstandard header



<< 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;
}
>>

 

singh

Golden Member
Jul 5, 2001
1,449
0
0
Your'e joking, right?

Runtime picture? Stack trace? I don't even want to think about those.. #2 seems pretty easy though.