C/C++ :: Reverse A String And State If It Is A Palindrome

Mar 28, 2015

I am supposed to take the three string lines from a text file and then individually reverse them and state whether or not they are a palindrome. I have the three lines from the text file into string variables already but I am not sure on how to reverse them and then see if they are the same reversed(palindrome)

Here is my code so far -->

#include <iostream>
#include <string>
#include <cctype>

[Code].....

EDIT: Ignore line 123 and down in the code. That was merely test code and will not be used.

View 7 Replies


ADVERTISEMENT

C :: Checking Whether A String Is Palindrome Or Not

Nov 4, 2013

Everything seems to be correct from my perspective. heres the program: Code: /*c program to check whether a string is palindrome or not*/

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

int main(void) {
char str[30];
int i,j,flag=0;

[Code] .....

View 1 Replies View Related

C++ :: Identifier String Value Is Palindrome Or Not

Feb 9, 2013

here is my code, the issue is its not determine if the value is a palindrome or not.

// unit 5b.cpp : Defines the entry point for the console application.
//
// How to read a file
// identify the string if its a palindrome or not
//

#include "stdafx.h"
#include <iostream>
#include <cctype>
#include <fstream>

[Code] .....

View 1 Replies View Related

C++ :: Check A String To Be Palindrome

Apr 23, 2014

I am trying to check a string to be a palindrome. I have tried using for loop but I am looking for most efficient way.

View 5 Replies View Related

C++ :: Program That Checks Whether A String Is Palindrome

Apr 27, 2014

Write a program that checks whether a string is a palindrome. A palindrome is a word, phrase, orsequence that can be read the same backward and forward.

Code:
#include<iostream>
#include<string>
using namespace std;
int main(){

[Code] .....

View 2 Replies View Related

C++ :: Program To Check Whether Or Not A String Is Palindrome

May 20, 2013

So I've been tasked with creating a program that checks to see whether or not a string is a palindrome. It has to remove whitespace, punctuation, and capitalization for obvious reasons. Getting some errors which I'm not sure how to correct.

On an unrelated note, while programming in the console, my cursor has turned into a gray box and replaces characters when typing, instead of pushing them forward, etc. How do I return it to normal?

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
bool isPalin(string& palin);
string cleanUp(string& palin);

[Code] .....

View 7 Replies View Related

C++ :: Palindrome - String Subscript Out Of Range

Jun 13, 2014

I am trying to create a simple palindrome program. I get the error string subscript out of range. I believe the error is either in the while or for loops.

#include <cctype>
#include <string>
#include <iostream>
using namespace std;
//cleans string, converts to lower
bool cleanTolower(const string& s);

[Code] ....

View 2 Replies View Related

C/C++ :: Find Out Whether A String Can Form A Palindrome Or Not

Sep 25, 2014

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
void findPalind(char *arr) {
int i,j,n,odd,flag=0,count[26]={0};

[Code] ....

This question was asked in Hackerrank. [URL] ....

I am able to get correct output upto a input of 50000 character string, but not for 100000 character string.

View 12 Replies View Related

Visual C++ :: Reverse String Sequence In String Buffer

Apr 27, 2013

I made a simple little program that takes text from the clipboard, and spits out all the lines I've copied one at a time (so my program can analyze it).

everything works perfectly, except, it spits it own in the wrong order, I want it to spit out from bottom to top. but currently it spits out the data from top to bottom. here is my code :

Code:
#include <iostream>
#include <Windows.h>
#include <string>
#include <sstream>
using namespace std;
int main() {
HANDLE clip; // assigns the var. clip to hold a handle ID.

[Code] .....

I want this loop to run backwards! Like it say's what I want to work backwards. Where as I know how to flip a while loop like this: while(x < 5), how to flip a loop like the one I'm using. how I can do this?

View 8 Replies View Related

C++ :: Determine Number Of Times Change Each Specific Character In String To Make It Palindrome

Feb 19, 2015

I'm trying to determine the number of times I have to change each specific character in a string to make it a palindrome. You can only change a character one at a time from the end.

Example: "abc" -> "abb" -> "aba" should print 2. "aba" will print 0 because it's already a palindrome. "abcd" -> "abcc" -> "abcb" -> "abca" -> "abba" will print 4 because it took 4 changes to make a palindrome.

I'm not too sure how to approach this - I figured out the case where if it's a palindrome (if reversed string is the same) then it'll print out a 0.

int main() {
int number;
cin >> number; //expecting a number for first line user input
for (int i = 0; i < number; i++) {
string str;

[Code] ....

View 1 Replies View Related

C++ :: Reverse Of A String

Dec 22, 2013

If I am executing following code after reversing it is giving "1" but I need "0001".

#include <stdio.h>
int main() {
int n=1000, reverse = 0;
while (n != 0) {
reverse = reverse * 10;

[Code] .....

View 11 Replies View Related

C++ :: Reverse A String In Place

Jan 12, 2014

I was browsing the web looking for simple yet fun programming challenges and crossed this one. I figured out how to reverse the string in place but I want it to read "blue is house the". I approached it in two ways for the heck of it. My idea was the second one, the first one I googled. I didn't know a simple rbegin() could do that, pretty neat.

I found the question here.[URL] ....

Code:
#include <iostream>
#include <string>
int main(int argc, const char * argv[])
{
std::string phrase = "The house is blue.";

[Code] ......

View 8 Replies View Related

C/C++ :: Reverse String Using Stacks?

Oct 29, 2014

As part of my hw assignment i need to reverse a string using stacks. This is my attempt and so far its not working.

// reverse.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"

[Code].....

View 3 Replies View Related

C# :: Reverse Chars Of String

Aug 7, 2014

I have a problem with my code. I just have to reverse the chars of a string, but it adds a /n that I can't delete.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ch05Ex05._5 {

[Code] ....

View 5 Replies View Related

C :: Reverse A String - Function Is Not Getting Called

Aug 29, 2013

I am new to C and trying to reverse a string but the function is not getting called.. the console says :

Enter a stringabhi
bash: line 1: 229 Segmentation fault (core dumped) ./program

Code:
#include<stdio.h>
#include<math.h>
#include<string.h>
char* reverseString(char input[]);
void main()

[Code] ....

View 6 Replies View Related

C :: Making A String Print In Reverse

Oct 15, 2013

Here's what I have to do: Using strcpy() pass it two strings of characters (such as a name like John Johnson) and copy the second string into the first, in reverse order, and print both. Write a main to exercise your function and to illustrate that the function is working properly.

View 4 Replies View Related

C++ :: Reverse Alternating Words In A String

Nov 24, 2014

I'm trying to create a small program to reverse every alternate words in a string.

OUTPUT: The esoum was thgauc in a peg.

#include<iostream>
#include<string>
using namespace std;
int main() {
string sentence, reversed_sentence, buffer;

[code].....

View 6 Replies View Related

C++ :: Unable To Reverse Even Words In A String

Nov 25, 2014

I'm trying to reverse every even word in a string (not all of it). But I keep getting an empty output.

For example:

The mouse was caught in peg.
The esmou was thgauc in gep.
Underlined words (even words)

#include<iostream>
#include<string>
using namespace std;
int main()
{
string text, result, temp;
int word_count(0);
cout << "Enter a sentence: ";

[Code]...

View 1 Replies View Related

C++ :: Reverse Alternate Words In A String

Nov 23, 2014

How do reverse every alternate words in a string that I read into my program:

e.g. The mouse was caught in a clothes peg.
reversed (including the full stop)
The esoum was thguac in a clothes gep.

I could program it to reverse the whole sentence. But no clue how to reverse certain words such as every even word. Do I need a function and/or loop to solve this?

#include<iostream> // allow input and output
#include<string> // allow for larger entries of characters
using namespace std;
int main() {
string sentence, reversed_sentence;

[Code] ....

View 4 Replies View Related

C++ :: Printing String In Reverse Order

May 14, 2014

How to print a string in reverse order(for example: "today is Wednesday " to "Wednesday is today"). My professor said we should begin with a null string and build it one word at a time.

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int nwords(string);

[Code] .....

View 1 Replies View Related

C++ :: Program To Reverse Input String

Nov 3, 2014

Explain this program to reverse an input string:

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main() {
void reverse(void);
clrscr();
reverse();

[Code] ....

Do not assume i know about getchar and putchar.

View 2 Replies View Related

C++ :: String Reverse Function - Array Declaration

Jan 23, 2014

Here's my program: - Program which inputs a string from user, reverses it and displays it.

#include <iostream>
using namespace std;
void string_reverse (char [], const int);
int main() {
const int arraysize = 10;
char string[arraysize];

[Code] ....

In the string_reverse function, I have declared temp character type array but on line 38, the

compiler is throwing 3 errors: -

error C2057: expected constant expression
error C2466: cannot allocate an array of constant size 0
error C2133: 'temp' : unknown size

I have declared a constant integer arraysize in line 35. Now I have no clue why is this happening because I think as I have declared it as a constant integer variable, this should not happen.

View 5 Replies View Related

C/C++ :: Strrchr Function - Search For A String From The Reverse

Feb 27, 2014

I understand that the strrchr function is supposed to search for a string from the reverse. Unfortunately, mine isn't doing that.

#include <stdio.h>
#include <conio.h>
int main() {
char userinput[100] = "null";
char searchchar;
char *s;
char try_Again;

[Code] ....

View 5 Replies View Related

C :: How To Print Out Output String For A Program In Reverse / Backwards

Feb 20, 2013

How to make it so an output for a program would print out the string in reverse/backwards? I was just curious on how to do this.

View 6 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++ :: Empty State Of Queue?

Feb 18, 2013

what is the empty state of queue?

View 5 Replies View Related







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