473,387 Members | 1,365 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,387 software developers and data experts.

How do I apply the 'toupper' to capitalize the first word?

g. 366*/

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <string.h>

int main (void)
{
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"};
char sentence[30];


int choice,i,a,a2,n,n2,v,p;
srand(time(NULL));

for(i=0;i<20;i++)
{
sentence[0] = '\0';
a = rand()%5;
n = rand()%5;
v = rand()%5;
p = rand()%5;
a2 = rand()%5;
n2 = rand()%5;

strcat(sentence, article[a]);
strcat(sentence, " ");
strcat(sentence, noun[n]);
strcat(sentence, " ");
strcat(sentence, verb[v]);
strcat(sentence, " ");
strcat(sentence, preposition[p]);
strcat(sentence, " ");
strcat(sentence, article[a2]);
strcat(sentence, " ");
strcat(sentence, noun[n2]);
strcat(sentence, ".\n");


printf ("%c");
}



system("PAUSE");
return 0;
}
Nov 8 '09 #1
3 2788
newb16
687 512MB
Apply it to sentence[0], that is the first letter of the first word in this case.
Nov 8 '09 #2
weaknessforcats
9,208 Expert Mod 8TB
toupper() converts only one character to upper case. You will need to apply it to all elements of the word.
Nov 9 '09 #3
newb16
687 512MB
I suppise the goal is to get a proper English sentence, where the first letter of the first word is capitalized.
Nov 9 '09 #4

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

Similar topics

7
by: Kerri | last post by:
Hi, I have a string 'hello world' I can UCase my string using String.ToUpper Is there anyway to just UCase the first letter ofe ach word? Thanks,
10
by: Aaron | last post by:
string a = "i have an apple"; i want the output to be "I Have An Apple"; i was able to capitalize the first word but can't figure out how to capitalize every word in that string Thanks,...
7
by: Marek Mand | last post by:
<script> var newval = ''; var name = 'marek mänd-österreich a'; // http://www.faqts.com/knowledge_base/view.phtml/aid/15940 correctedname = name.replace(/\b\w+b/g, function(word) { return ...
3
by: gil | last post by:
I have a script that will capitalize the first letter of every word in my descriptions. But some of my descriptions contain ( ) and /. For example bezel (black). I need the script to capitalize...
1
by: Dwight Shubert | last post by:
Hi all, This is my first try using Access. I understand how to format a text field for uppercase and lowercase, but how do you capitalize only the first letter of each word? tia Dwight
4
by: Claudia Fong | last post by:
Hi, I'm trying to convert a string into a Upper case; in the book said that I need to use ToUpper(the string that I want to convert to upper case) but it happens that C# "generate" the error...
1
blyxx86
by: blyxx86 | last post by:
I have the code to capitalize an entire string when it is input, but would like to capitalize just the first letter of a box, or match the case of a drop down list.. My current code is thus: ...
7
by: dizzylizzyd514 | last post by:
I need to make this: introductoRy speEch ==> Introductory Speech pRecalCulus 1 and 2 ==> Precalculus 1 And 2 I know how to capitalize the first letter of a word, but not multiple words in a...
12
by: jackson.rayne | last post by:
Hello, I am a javascript newbie and I'm stick at one place. I have a requirement where I will get a sentence in a variable example var v1 ="This is a sentence"
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.