C/C++ :: Recursive Function To Move Specific Characters To End Of String?
Oct 16, 2014
I am attempting to write a recursive function that, given a string, recursively computes a new string where all the lowercase 'x' chars have been moved to the end of the string.
For example,
moveXs("xxre") --> "rexx"
moveXs("xxhixx") --> "hixxxx"
moveXs("xhixhix") --> "hihixxx"
Below is the code I have written thus far, but it seems to be returning only empty strings.
string moveXs(const string& str) {
string strCopy = str;
if (strCopy.length() <= 1) {
return str;
[Code] ....
View 6 Replies
Mar 15, 2014
Eg. User input : abcde
Program Output : edcba
I keep on getting weird ASCI symbol in return, I couldn't achieve what I need, and tried debugging for days,
Code: char ar[20];
int len,n=0;
printf("enter the string to be reversed :
");
[Code].....
View 5 Replies
View Related
Dec 3, 2013
How to move a character (an arrow or any other character) on screen using keyboard? I'm actually a beginner and have only wrote simple (starter's) programs in C++. It would be great without using any external library which is not included in C++ by default (in other words, using plain C++).
View 8 Replies
View Related
Dec 7, 2013
I can not cope with the task.Create a function that will take a string of characters (including spaces) and print the numbers of characters (including commas, periods, etc.) in it. The output will be arranged alphabetically. Distinguish case sensitive!
View 6 Replies
View Related
Feb 1, 2014
I wrote a function to count the number of characters in a string. Curious as to why I have to return x-1 and why x isn't the number of characters.
Code:
int count(char *string){
55 int x = 0;
56 char *p;
57 p = string;
58
[Code] .....
View 4 Replies
View Related
Feb 23, 2015
I have been skimming and searching but dont know how to word the search just right to find what I need to know. I have written simple stuff with the support of tutorials like weight conversion or loops counting up to a set number. Nothing amazing. The other day I found out how to input and print a string rather than a single text character which i though was bad ass. I even got it to read multiple strings on a single line and found a way to read multiple lines. I can even format it to read both integers and characters on the same line as long as I know the predefined format.
On to my question... How do I read multiple lines with both carecters and integers. for instance:
nissan 1996
toyota 1998
or more comples like
nissan gtr 1996
toyota markii 1998
I want to use
int year;
char make[10]; maybe need to use char make[10][10]; for an array i would guess.
char model[10]; optional for the extra data
but reproduce what i read in a different order. say...
1996 nissan
1998 toyota
vice the original format.
this is what I have tried.
Code: scanf("%s %s", &make,&year);
//The way I seen to read multiple lines was on here
scanf("%[^/t]", %make);
But this wont let me separate the two into two differnet definded data types. Let alone use printf to display them in reverse order.
View 1 Replies
View Related
Mar 20, 2014
so my question is i want to print characters,no string just an array of characters,i do this but it s not working,maybe i have to put the '' at the end?
Code:
int main() {
int i;
char ch[5];
for(i = 0; i < 5; i++) {
scanf("%c",&ch[i]);
[Code]...
View 6 Replies
View Related
Jul 6, 2014
Im supposed to find the common characters between two string characters, assuming that the user wont input duplicate letters like ddog. When I run my code I get an output of a question mark upside down. Here is my code with comments on what each part is supposed to do
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(){
char str1[20], str2[20],remp = '