HELPPPPPP

When i compile this happenes can anyone help
Enter the lines of poetry you want
8

A gawl-dern old junk and sheriff drink trash
hy is it umm
jail-foodp▒▒B▒▒C▒CX▒▒BP▒▒B▒]▒B ▒X▒B▒▒▒P~&▒▒]▒B&▒ }&▒@Y▒B▒X▒B▒X▒B▒
you like to make another poem?
n
Thank you for sharing you poerty come back again to share
=-------------------------------------------------------------------------------










header.h file

#include <fstream>
#ifndef HEADER_H
#define HEADER_H
using namespace std;

const int SIZE = 50;
void nouns();
//Pre:None
//Post: Print out random nouns

void adjectives();
//Pre:none
//Post: Print out random adjs.

void verb();
//Pre:none
//Post: Print out random verbs

void pronouns();
//Pre:none
//Post: Print out random pronouns

void adverbs();
//Pre:none
//Post: Print out random adverbs

void interjections();
//Pre:none
//Post: Print out random interjections

void greet();
//Pre:None
//Post: Greet the user

void quit();
//Pre:None
//Post: sign off message

bool openfiles(ifstream & my_stream);
//Pre: parameters is set by reference with my_stream
//Post:openfile is either true or false

void patterns(const int line_numb);
//Pre:parameters is > 0
//Post: Print out random patterns

#endif
-------------------------------------------------------------------------------





main.cpp

#include <fstream>
#include <cstdlib>
#include <cstring>
#include <string>
#include "header.h"
using namespace std;


int main()
{
srand(time(NULL));
int line_numb;
char loop;
greet();

do
{
cout<<"Enter the lines of poetry you want"<<endl;
cin>>line_numb;
patterns(line_numb);

cout<<"Would you like to make another poem? "<<endl;
cin>>loop;
}while(loop == 'y');
quit();
return 0;
}

--------------------------------------------------------------------------------



functions.cpp

#include <iostream>
#include <fstream>
#include <cstdlib>
#include "header.h"
#include <cstring>
#include <string>
using namespace std;


void nouns()
{
int position; //count
int numb_entries;
char word[SIZE];
ifstream noun;


noun.open("nouns.dat");
noun>>numb_entries;
noun.ignore(SIZE, '\n');
position = rand() % numb_entries;
for(int i = 0; i <= position; i++)
{
noun.getline(word,SIZE - 1, '\n');
}
cout<<word;

noun.close();
return;
}
void adjectives()
{
int position;
int numb_entries;
char word[SIZE];
ifstream adjective;

adjective.open("adjectives.dat");
adjective>>numb_entries;
adjective.ignore(SIZE, '\n');
position = rand() % numb_entries;
for(int i = 0; i < position; i++)
{
adjective.getline(word,SIZE - 1, '\n');
}
cout<<word;
adjective.close();
return;
}
void verbs()
{
int position;
int numb_entries;
char word[SIZE];
ifstream verb;

verb.open("verbs.dat");
verb>>numb_entries;
verb.ignore(SIZE, '\n');
position = rand() % numb_entries;
for (int i = 0; i < position; i++)
{
verb.getline(word,SIZE - 1, '\n');
}
cout<<word;
verb.close();
return;
}
void pronouns()
{
int position;
int numb_entries;
char word[SIZE];
ifstream pronoun;

pronoun.open("pronouns.dat");
pronoun>>numb_entries;
position = rand()% numb_entries;
for(int i = 0; i < position; i++)
{
pronoun.getline(word,SIZE - 1, '\n');
}
cout<<word;
pronoun.close();
return;
}
void adverbs()
{
int position;
int numb_entries;
char word[SIZE];
ifstream adverb;

adverb.open("adverbs.dat");
adverb>>numb_entries;
position = rand() % numb_entries;
for(int i = 0; i < position; i++)
{
adverb.getline(word,SIZE - 1, '\n');
}
cout<<word;
adverb.close();
return;
}
void interjections()
{
int position;
int numb_entries;
char word[SIZE];
ifstream interjection;

interjection.open("interjections.dat");
interjection>>numb_entries;
position = rand() % numb_entries;
for(int i = 0; i < position; i++)
{
interjection.getline(word,SIZE - 1, '\n');
}
cout<<word;
interjection.close();
return;
}
void patterns(const int line_numb)
{
int position;
int numb_entries;
char sentence[SIZE];
int line = 0;
int i = 0;
ifstream pattern;

while(line < line_numb)
{
pattern.open("patterns.dat");
pattern>>numb_entries;
pattern.ignore(50, '\n');
position = rand() % numb_entries;
sentence[0] = '\0';
for(int a = 0; a <= position; a++)
{
pattern.getline(sentence, SIZE-1, '\n');
}
pattern.close();
cout<<'\n';
while(sentence[i] != '-')
{
if(sentence[i] == '1')
{
nouns();
}
else if(sentence[i] == '2')
{
adjectives();
}
else if(sentence[i] == '3')
{
verbs();
}
else if(sentence[i] == '4')
{
pronouns();
}
else if(sentence[i] == '5')
{
adverbs();
}
else if(sentence[i] == '6')
{
interjections();
}
else
{
cout<<sentence[i];
}
i++;
}
line++;
}
cout<<" "<<endl;
pattern.close();
return;
}
void greet()
{
cout<<"Welcome to to Poerty Slam everyone"<<endl<<endl;
return;
}
void quit()
{
cout<<"Thank you for sharing you poerty come back again to share"<<endl;
Topic archived. No new replies allowed.