473,327 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

help with a program

hi,
I'm trying to write a program in wich I would generate 20 sentences out of
4 arrays(articles,nouns,preposition,verb).I have to select an item at random
from each array and concatetane each one of those selections to form a sentence,
I have to form 20 sentences. I have no compiling errors but when I execute
the program is giving an execption. This is the code I have


// program uses randon number generation to create sentences

#include <iostream.h>
#include <stdlib.h>
#include <time.h>

#include<ctype.h>
#include<string.h>

const int row= 20;
const int column= 80;
void touppercase(char *string);
void concatenate(char *array[][column],int element,char *string[],int size);


int main()
{

srand(time(NULL));

char *array[row][column] = {" "};
int position= 0,
counter= 1;
char *article[5]= {"the","a","one","some","any"};
char *noun[5]= {"boy","girl","dog","town","car"};
char *verb[5]= {"drove","jumped","ran","walked","skipped"};
char *preposition[5]= {"to","from","over","under","on"};

do
{


if(counter == 20)
touppercase(article[position]);

concatenate(array,counter,article,row);

concatenate(array,counter,noun,row);

concatenate(array,counter,verb,row);


concatenate(array,counter,preposition,row);


}while(counter < 21);
for(int i =0;i<20;i++)
for(int j =0;j<20;j++)
cout<<array[i][j]<<endl;

return 0;
}

void touppercase(char *string)
{
int i =0;
while((*string != '\0') && (i != 1))
{
*string = toupper(*string);
++i;
}
}
void concatenate(char *array[][column],int element, char *string[],int size)
{
int position = 0;
position = (1 + rand() % 5);
strcpy(array[element][column],string[position]);
}

any suggetion on this will be greatly appriciated.
Thanks,
Oct 29 '06 #1
2 1707
can any one help please..
Oct 30 '06 #2
I need help please...
Oct 30 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: PHPkemon | last post by:
Hi there, A few weeks ago I made a post and got an answer which seemed very logical. Here's part of the post: PHPkemon wrote: > I think I've figured out how to do the main things like...
6
by: wukexin | last post by:
Help me, good men. I find mang books that introduce bit "mang header files",they talk too bit,in fact it is my too fool, I don't learn it, I have do a test program, but I have no correct doing...
5
by: Bec | last post by:
I'm in desperate need of your help.. I need to build an access database and have NO idea how to do this.. Not even where to start.. It IS for school, and am not asking anyone to do my...
7
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that...
2
by: Erik | last post by:
Hi Everyone, I'm having real problems compiling some source for eVC4++. The errors I am getting are below: It all seems to be centred around winsock. If I move the afsock.h reference to before...
2
by: Bsnpr8 | last post by:
I need help guys, i have to many stuff to do, because i am in my last 2 weeks of the university, my last assignment is to do a spell checker in C++, i have an idea but nothing is coming out. I really...
6
by: HelpME | last post by:
I wrote a program in Vb.Net that was running fine. However I am unable to install it on a couple of machines. When i run it I get a windows error message that says My Project.exe has...
1
by: ligong.yang | last post by:
Hi all, I got tortured by a very weird problem when I was using k. wilder's random generator class in my program. PS: wilder's generator class can be found at...
1
by: ligong.yang | last post by:
Hi all, I got tortured by a very weird problem when I was using k. wilder's random generator class in my program. PS: wilder's generator class can be found at...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.