C/C++ :: Convert 1st Letter Of Each Word To Uppercase And Then Display Only The Last Word?
Dec 27, 2013
I want a program to display as follows..
if i enter mohandas karamchand gandhi i want output as M K Gandhi.....
i want the c++ code for this program..my error is i am not able to erase the letters of first 2 words..ie my output is Mohandas Karamchand Gandhi..
View 2 Replies
ADVERTISEMENT
Sep 22, 2013
I need to write a C program to make the user input some text,and the first letter of each word has to be uppercase.(have to use while loops)So for example lets say the user inputs:
i lOvE pRoGrAmMiNg
The output needs to be:
I Love Programming
Code:
#include <stdio.h>
int main()
{
int i = 0;
char c, lower_c;
printf("Enter text
");
[code]....
I have started this code by making the letters lowercase.I am not sure how proceed after this step, the step of making the first letter uppercase.
View 2 Replies
View Related
Feb 28, 2014
The problem I am facing is that I have to output the C++ input file and display every line of code in the output, except in the output I have to convert every if, else, and while as IF, ELSE, WHILE. I tackled the first part and now its onto the 'easier' part even t
View 1 Replies
View Related
Dec 10, 2014
Write a program that inputs a string and then converts each 1st letter of a word in the string into capital case. An example run of the program is shown below:
Enter string: introduction to programming
Output string: Introduction To Programming
View 1 Replies
View Related
Feb 18, 2013
I am building a linked list and i need to display function i have. The display function displays all the letters of the word entered instead of the word itself. below is my struct, one of my functions and the display function.
Code:
//-----------struct ------------//
struct Node
{
char data;
struct Node *next;
}*Head;
[code]....
View 1 Replies
View Related
May 3, 2014
What I am trying to do is read a sequence of words from cin and store the values on a vector. Then process the vector and change each word to uppercase.
I know line 21 is the problem. I think I don't have the right syntax. That syntax works on string. I'm trying to adapt and use it on vector but it doesn't work.
#include <iostream>
#include <string>
#include <vector>
int main()
[Code]....
View 7 Replies
View Related
Jan 7, 2014
I have a difficulty with string methods for some reason. I tried solving a question from my book, which requires me to capitalize the first letter of every word in a string. I kept trying for maybe two hours yesterday, re-reading the string chapter to see if I'm forgetting a certain method or if something similar was discussed in the examples but I didn't find anything. I also googled it, and found a few answers, none of which I understood. They mostly had keywords or methods I wasn't familiar with. Anyway, here's where I am so far.
class Program {
static string UpperCase(string s) {
int place; string b, st1, st2,st3; char letter;
for (int i = 0; i <= s.Length - 1; i++) {
if (i == 0) {
[Code]....
The code compiles without any errors, but when I enter a string it capitalizes correctly for the first two words and then it starts capitalizing letters in the middle of the words.
View 14 Replies
View Related
Mar 30, 2014
I need to reverse a word . For instance "Hello" after reversing will be "olleh" . It reverse first and last letter but its not reversing the rest of them
char arr[]="Hello";
int first=0;
int last=sizeof(arr-1);
int mid=sizeof(arr)/2;
[Code] ....
View 2 Replies
View Related
Aug 22, 2014
I have one string from user. Let say,
"The deviceId is 2"....but user also can give input like this..
"The deviceId is a".
I just need to know how to differentiate a word/letter and number in the string.
View 1 Replies
View Related
Jun 25, 2014
Basically I have a text file called words. I'm supposed to extract a word randomly form the file and have the user guess the word. If they guess the word correctly in x number of tries they will receive the definition.
I'm having trouble receiving that random word and I'm getting the definitions from the file.
Here's my code:
#include <iostream>
#include <fstream>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
using namespace std;
[Code] ....
This is what is in the words.txt file
apple#the usually round, red or yellow, edible fruit of a small tree
boat#a vessel for transport by water
horse#a solid-hoofed plant-eating domesticated mammal with a flowing mane and tail, used for riding
television#a system for transmitting visual images and sound that are reproduced on screens
soup#a liquid dish, typically made by boiling meat, fish, or vegetables, etc.
bottle#a container, typically made of glass or plastic and with a narrow neck
barber#a person who cuts hair
toast#sliced bread browned on both sides by exposure to radiant heat
radar#a system for detecting the presence, direction, distance, and speed of aircraft, ships, and other objects
red#of a color at the end of the spectrum next to orange and opposite violet
View 3 Replies
View Related
Oct 24, 2013
I'm learning programming, and C++. I've got a question, but I couldn't solve my problem so far. I need to use arrays and only basic stuff to solve this:
Create a program that reads a word from the user and then print (cout) this word on contrary. It's simple, I know, but I can't do it,. I've tried some stuff but I don't get how I will get the proper values to do this. All I know is that I can use variable.lenght().
View 7 Replies
View Related
Mar 20, 2013
I have a problem to open word document into turbo c++. i don't know how to open if the documents are in word format.
View 1 Replies
View Related
Apr 25, 2012
I've taken part the text into 1 word per line, but I can't figure out how to printf every word only once and then add (%d) in the end to show how many repetitions of that word there are.
Code:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
using namespace std;
int main(){
char *oneword;
[Code] ....
View 3 Replies
View Related
Dec 20, 2013
I have text (string) and I want to find a given word (it's ok!) and then insert another given word after the first word. The original string is beeing copied into a new string. But something is going wrong!!! Where is my mistake?
(I have some patches...)
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//insert "new_word" after each occurence of "word"
int main(){
char A[100]="In the sentence words the and the.";
[Code]...
View 8 Replies
View Related
Aug 6, 2013
int countTextWords(ifstream * file)
{
string textWord;
int wordCount = 0;
while((*file) >> textWord)
{
wordCount++;
}
return wordCount;
}
for some reason, (*file) >> textWord will not read words into the string. What am I doing wrong?
View 9 Replies
View Related
Jan 28, 2015
Having problem with my code. i keep getting an error towards the bottom of the code. i need the user to enter a word. and with that word convert it to numbers. once i have convert it if it is bigger than 20 i have to add the two digits together and get print out the array that response to it.
example" ALEX
A=1
L=12
E=5
X=23
1+12+5+23= 41 //since its bigger than 20 you add 4 and 1 together so it will be 5. after that you print the 5th element of array
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
[Code]...
View 2 Replies
View Related
Jun 5, 2013
i want to create a program (in c++ or c#) that will play mp3 files but also display a word file with the lyrics of the mp3 song playing. so if i choose a mp3 file from a list, the lyric file for that song should also be displayed. i have all the mp3 and lyric files saved on the computer so my problem is how can i link the files?
View 5 Replies
View Related
Aug 14, 2014
ow to read word by word from a line in file into struct. Say for example:
12345 Joe Lim KH879.00
12233 Kay Suet Yee35.98
to
struct master {
unsigned short int IDnum;
char name[30];
float salesCustomer;
};
View 1 Replies
View Related
Oct 20, 2014
I am now making a Dictionary using C++. My goal is to search the word and display the definition of the searched word from the text file. I have a code but it is not working. How can I search a word and display the definition of the word from a text file?
void searchFile(string word) {
ifstream ifile;
ofile.open("dictionary.txt", ios::in);
string line;
string search;
[Code] ....
View 1 Replies
View Related
Apr 1, 2014
i've been trying to figure out to search for a word in a text file and then display everything in the same row as the word found int ie this is whats in the file
john doe 3/21/1920 tech support review team 45,000
so user wants to find tech..and everything associated with it.
so program search for tech, when it does it then display the whole row.
john doe 3/21/1920 tech support review team 45,000
I can figure out how to search for a word, but no clue how to get it to then print out the row. This is all I can figure out to do.
ifstream FileSearch;
FileSearch.open("employee");
if(FileSearch.is_open())
{string letters;// search word would be store here
string row; ??stores entire row as string
while(1)
[Code]....
View 14 Replies
View Related
Apr 25, 2013
i'm making a program for basic data entry.i have also included search feature which uses strcmpi() function.if i have a file name'report on tigers' and someone searched for 'tigers' then that person will not find the required file.any way i can overcome that ?
View 2 Replies
View Related
Apr 28, 2013
tell me how to loop through a string and uppercase each letter?
View 1 Replies
View Related
Apr 26, 2014
Write A Program which converts a string of uppercase letters into its corresponding lowercase.Using pointers to access the members of the Array.
Write A program that reads eight float numbers into an array and then print out the second,fourth,sixth and eight members of the array,
And Sum of the first,third,fifth,and seventh. Using pointers to access the members of the array.
View 2 Replies
View Related
Mar 16, 2013
im trying to capitalize every other word. for examples input: hello output: HeLlO
View 5 Replies
View Related
Mar 1, 2015
So this is my homework: a user will enter a line of text, echo the input one word per line and capitalize each word(do not use toupper) and also needs word count and punctuation marks count. I know how to echo one word per line. How to capitalize each word without toupper? and how to do word count?
View 3 Replies
View Related
Nov 18, 2013
I would like to know how I can know if a word is before another in a string. Here's my current code.
#include <iostream>
#include <math.h>
#include <string>
#include <cstdlib>
#include <sstream>
#include <vector>
#include <iterator>
using namespace std;
int main() {
string equation;
getline (cin, equation);
[Code] .....
View 9 Replies
View Related