C/C++ :: Reverse A Word - Only First And Last Letter Reversed

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


ADVERTISEMENT

C :: Store Character Array In Reverse Order Then Display Reversed Array

Jun 14, 2013

The program should store a character array in reverse order then display the reversed array. I have also included in the code that will display the actual characters into the array as it loops through. So I know the characters are being stored, but why doesn't it display the entire string when I call it?

Code:
#include<stdio.h>
int main(){
char str[50];
char rev[50];
printf("Enter Desired Text: ");
scanf ("%[^

[Code] ....

Is it just my compiler?

View 5 Replies View Related

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 View Related

C# :: Capitalize First Letter In Every Word In A String?

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

C++ :: Differentiate A Word / Letter And Number In A String

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

C :: Make First Letter Of Each Word In User Input Text Uppercase

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

C++ :: Input String And Then Convert Each 1st Letter Of Word Into Capital Case

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

C++ :: Making A Program Read A Word In Backwards / Reverse?

Feb 26, 2014

Lets say I have my name "Kevin".

What would the program be so it reads "niveK"?

How to write the program for that?

View 4 Replies View Related

C++ :: String Copy - Program To Reverse Word Order In Sentence

Apr 2, 2012

I am trying to write a program that takes a sentence and reverses the word order.

For instance This is a Bird would become Bird a is This

Code :

#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main (void) {
char input_buffer[1024];
char middle[1024];

[Code] ....

View 3 Replies View Related

C :: Input A String And Get It Reversed

Sep 15, 2013

So I was trying to input a string and get it reversed. I came up with his code. It is supposed to work by first creating two strings, then I get the input of a string and then try to reverse it using a while loop. However the output each time is pure garbage, what exactly have I overlooked?

Code:
#include <stdio.h>#include<stdlib.h>
int
main (void) {
char z[255];
char y[255];

int x,r=0;

[Code] .....

View 2 Replies View Related

C/C++ :: How To Make Input By The User Show Up Reversed

Feb 6, 2014

#include <stdio.h>
#include <string.h>
#define MAX 1000
main()
{
char text[MAX], c;
int i,s;

[Code]...

I need to edit the code here to make the input by the user show up reversed

puts("
Your reverse input is:");
for(i = length - 1; i >= 0; i--){
printf("%c",text[i]);
}

I know this is not right...

View 4 Replies View Related

C++ :: Hangman Definition Game - Extract Word Randomly Form File And User Guess The Word

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

C :: Display Function Displays All Letters Of Word Entered Instead Of Word Itself

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

C++ :: Program That Reads A Word From User And Then Print (cout) This Word

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

C/C++ :: Opening Word Document In Turbo Or Any Program In Word Format

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

C++ :: Simple Word Counter - Show Repetition Of Word

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

C :: How To Find Word And Insert Another Word After That In Text

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

C++ :: Fstream Class Not Reading Word For Word

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

C++ :: Word By Word From A Line In File?

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

C :: Word By Word Search

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

C :: Know If Letter Is Inputted Twice

Sep 23, 2013

how can my program read if a letter is inputted again it prompts "letter inputted already"? heres my code:

Code:

#include <stdio.h>
#include <string.h>
#include <conio.h>

[Code].....

View 8 Replies View Related

C :: Capitalize Letter Without Using Arrays

Oct 28, 2014

Can I capitalize first letter of each word without using arrays ? If yes, how can I ?

View 11 Replies View Related

C++ :: Letter Frequency For A Vector

Nov 9, 2013

I am trying to print out the letter frequency of a vector that the user inputs and what number that letter is in the ASCII. I am supposed to say, for example: "w" which is ASCII 119 occurs 2 times. How to do this?

View 1 Replies View Related

C++ :: Replace 2nd Occurrence Of Letter?

Apr 27, 2013

i`m currently racking my brains out over this issue. How do i go about the x as the first occurrence of the letter?

lets say helxo , x is the 2nd occurrence of l. I will want to change back x into l

i have replaced it with x in the earlier step with this code...

string everySecondChar(const string &s,char source,char distance)
{
string t(s);
for(std::string::size_type even =0,pos=t.find(source,0);pos!=std::string::npos;pos=t.find(source,++pos))
{

[Code]....

i would like to reverse the process now, letting x becoming l again!

View 10 Replies View Related

C++ :: Letter Frequency Count

Nov 13, 2013

I am new to c++. I am writing a program that reads in a text file and gives a count of how many times each letter appeared in the file. I got it to read the text file and do the letter count. B

X = 102
Y = 126
Z = 165
etc...

THAT IS WORNG

The sample output should be
E = 165
T = 126
A = 102
O = 93
etc...

I got it to sort from lowest to highest for the frequency, but cant seem to get the appropriate letter assigned to it.

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

[code].....

View 1 Replies View Related

C++ :: How To Replace 2nd Occurrence Of A Letter With X

Apr 21, 2013

Supposed i have a word hammer.

how am i suppose to search for the 2nd occurrence of the letter and then replace it with x?

example hammer will become hamxer

I thought about using replace for it, however i`m lost on how to find 2 occurrences of the same letter in the word.

string formatEncrypt(string message) {
int msgLength=message.length();
for(int i=0;i<msgLength;i++) {
if(message[i] == 'j' {
message[i]='i';

[Code] .....

at line 31 i tried to put a z into the alphabet that occurs twice.

this is what i have done so far

example: hello world

It will turn out as helzlo world

However i want to make the output appear as helzo world

View 6 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved