C/C++ :: Find If A String Contains A Quoted String?

Oct 23, 2014

bool isQstr(string const& str)
{
size_t found = str.find(""");
return found != string::npos;
}
/*

I am trying to check whether a string contains a quoted string, I used the escape character but it does not even recognize it*/

View 1 Replies


ADVERTISEMENT

C :: How To Find ASCII Value Of Given String

Aug 25, 2013

I know how to find find ASCII value of given character, but I am not getting how to find ASCII value of given string. For example I want to find ASCII value of string "HELLO",so how to do that.

View 13 Replies View Related

C++ :: Find String In Vector?

Oct 15, 2013

So the program reads contents from a text file into a vector and then the user enters in a string that they want to search for. The program iterates through the vector to find the string and then saves that line to another vector to display later(incase there is more then 1 instance of the string found).

Here is what I have atm:

void doSearch(vector<string> &phonelist, string searcher, vector<string> &holdNumbers)
{
int i = 0;
string value;

[Code].....

I just get an R6010 error -abort() has been called.

View 2 Replies View Related

C++ :: How To Find Length Of String

Jul 6, 2014

int t;
string a;
cin>>t;
getline(cin,a);
int len=a.length();
cout<<a<<" "<<len;

[code].....

why is the length 0?what can I do to get the correct length of the input string?

View 5 Replies View Related

C/C++ :: Find Length Of String

Dec 15, 2014

I am stuck here.

printf(" Enter a line of Morse Code for decrypting");
scanf("%s",phr);
len=strlen(phr);
for(a=0;a<36;a++) {
if(strcmp(phr, morse[a])==0)
printf("%c", alpha[a]);
};printf(" ");

The output :

[output] Enter line to encrypt:
..... -.... --...

converting...
5 [/output]

It should read all code, including null. between coded letter one space, between coded word three spaces.

The output should be:

[output]
56 7 [/output]

View 9 Replies View Related

C++ :: Find Substring From A String

Apr 23, 2012

I am stuck in some logic and want to write a program to do following tasks : I have three string variables to be compared to each other,a string having sub string & hierarchy string!!

1.) name1=john name2=tom_john_tom name3=alextom_john
thus we need to search john from name2 and name3 and if name1 exists in both name2 and name3 then ok else check for step2

2.) name1=a.b.c.d ,name2=a.b.c.d and name3=a.b.c.d
we need to compare each string seperated by a dot in all three variables and we need to match each string seperated by a delimeter "."
if name1.a==name2.a==name3.a and name1.b==name2.b==name3.b ,name1.c==name2.c==name3.c and name1.d==name2.d==name3.d then its a match
else its a mismatch

Also,the catch is we can have name1 ,name2 and name3 in format name1=*.*.*.* and name2=*.*.*.* and name3=*.*.*.*
where * defines it can be any value to be matched

name1=government.india.public.property
name2=rural.roads.maximum.x
name3=government.india.public.sales
name4=rural.roads.minumum.x

If operator wants to match only the second field , then the logic should be like:

If the Value is to be matched = (*.#.*.*)
then "matched"
Else
its a mismacth

# => for this field of name2 and name3 shall be same
* => for this field name2 and name3 shall be ignored for comparison

to obtain option1 we can have find function and substr however pls suggest how to approach for second option !!!!

View 1 Replies View Related

C++ :: Find First 10 And Last 10 Words Of String Array

Jan 26, 2015

I got a homework that require to count number of words in a text file and also display the first and last 10 words of the text file to the console. I have finished the counter problem and now I struggle showing the first and last 10 words.

#include <iostream>
#include <sstream>
#include <string>
#include <fstream>
using namespace std;
int tokenize(string sentence, string tokenizedWords[]);

[code]....

View 2 Replies View Related

C++ :: How To Find Position Of Certain Character In String

Jan 11, 2013

I need to find position of certain character in string, so i made a function but it doesn't do what i thought it would.

Consider this string:

std::string line = "<foo> <foo> <foo> <foo> <foo>"

I need to find position of a third '>' character so i can get:

std::string other = "<foo> <foo> <foo>";

This is my function that fails:

std::size_t find_third(const std::string& line) {
std::size_t pos = 0u;
for(std::size_t i = 0; i < 3u; ++i) {
std::string tmp = line.substr(pos);
pos = tmp.find_first_of('>');
} return pos;
}

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

C++ :: Find The Highest Digit Within C-String

Oct 27, 2014

I can't find the highest digit within c-string. Ithe user was to enter 1234. the highest shall be 4 but can't get that number.

int Hnum(char* str) {
//int size = 0;
int H = 0, remainder, div =0;
int intstr = atoi(str);

[Code] ....

View 2 Replies View Related

C/C++ :: Find Last Longest Word In A String

Apr 29, 2015

How to find the last longest word in a string when there are more of them (with the longest size)?

Here is the program for the longest without checking if last:

#include<stdio.h>
#include<string.h>
int main() {
char a[50],b[20],c[20];
int i,j=0,l=0;
printf("Enter a string:
");
gets(a);

[Code] ....

View 6 Replies View Related

C :: Find Highest Frequency Character In A String

May 17, 2014

The code shows all characters frequency, however i want to find which one has highest frequency

For example cprogrammmmming cboard
highest frequency: m

Code:
char string[100], ch;int c =0, count[26]={0};
printf("Enter a string
");
gets(string);

[Code] ....

View 3 Replies View Related

C++ :: Find / Calculate And Replace A String In A File

Feb 3, 2013

i have a text file... with example following content:

Pizza 23232
Car 44,495
Drink 3493,90494
....
..
.

and so on..

no i want to find the 44,495 in this textfile.. calculate a new value like 44,495 x 2 + 5

and write the same file as

Pizza 23232
Car 93,99
Drink 3493,90494
....
..
.

back..

View 2 Replies View Related

C++ :: Find Frequency (string Into Struct Array)?

Apr 17, 2013

I'm trying to figure out the word frequency of a user inserted string. I've tried doing it via getline of the struct array and via the getline of the string word but neither either the former crashes or the latter just prints out the whole string.

Here is the latter.

#include "stdafx.h"
#include <iostream>
#include <string>
#define MAX_WORDS 200
using namespace std;

[Code] ....

How to handle the array of structs.

View 5 Replies View Related

C++ :: Multiply String To Int - Could Not Find Match Operator

Jan 5, 2015

Whats wrong with my program ? It always says that coundn't find match operator ? What can i do ? I want to multiply string pay to int HOURS.

#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main () {
system("color 8e");
string ID,name, address,No, pos ,pay, hanap;
string hours;

[Code] .....

View 3 Replies View Related

C/C++ :: Word Maze - Find String In Vector

Mar 4, 2015

This program is to solve a word maze and find the number of words in the maze from a dictionary file.

The program runs, but stops by finding 1,2 and 3 letter words.

#include<iostream>
#include<vector>
#include<fstream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
vector <string> dict,forward,reverse;

[Code] .....

I also tried to find words using the entire vector as a container, the synopsis code that also did not work is below

while(j<dict.size()) {
if(dict[j].size()>2) {
if (std::find(forward.begin(), forward.end(), dict[j]) != forward.end()) {
cout<<"found word "<<dict[j]<<endl;

[Code] ....

Attached File(s)

dumpling2.txt (2.54K)

Dictionary.txt (718.34K)

View 13 Replies View Related

C/C++ :: Find Length Of First Sentence In Input String

Feb 13, 2015

I have a question about finding the length of first sentence in an input string.

For example, let the input string be: dream in code. community learning

The length of first sentence is 13 (blanks are included). My question is how to create conditions for multiple punctuation signs (!,?)? If while loop goes like:

while((str[i]!='.')||(str[i]!='!')||(str[i]!='?'))

it gives me an error for infinite loop.

Code:
#include<stdio.h>
int main() {
char str[100];int i=0,br=0;
printf("enter a string:");
gets(str);

[Code] ....

View 1 Replies View Related

C/C++ :: Scan Through One String To Find A Letter That Also Appears In Another?

Feb 3, 2015

I need a code that will search through string 1 and find the first place with a letter that also appears in string 2 and return the pointer of that place. This is what I wrote:

char strPbrk(const char *s1, const char *s2) {
char p = *s1;
for (int i = 0; i < strlen(s1); i++)
for (int j = 0; j < strlen(s2); j++)
if ((p+i) == *(s2+j))
return p;
return NULL;
}

but it continues to return wrong values idk what I'm doing wrong.

View 4 Replies View Related

C++ :: Find String To Erase Symbol From The End Of A Word

May 2, 2013

I'm trying to use the find string to erase a ' ' from the end of a word. I tried something along the lines of:

if (SecondSide.find('
')!= string::npos)
SecondSide.erase(SecondSide.find('
'));

but it had no effect.

View 7 Replies View Related

C/C++ :: Find Repeated Words In String And Symbols Between Them

Oct 29, 2013

I need to find 2 similar words in one sentence and i need to find how much symbols are between these two words. I can't figure out the algorithm.

For example sentence would be-

This is nice table and nice chair.

Similar words are- nice

Symbols between them are 11 or 8(dont know if space is count as symbol)

int main()    
char text[200],*dist;
printf("Enter one sentence 
 ");
gets(text);

Maybe first of all would be

dist=strtok(text, " ,.!?");
while(dist!=0)
{
 printf("%s
", dist);
 dist=strtok(NULL, " ,.!?");
 }  

and it wil output each word and maybe then can search for similar words if there would be 2 strings then i would use strstr but i dont know how to do with one string.

View 1 Replies View Related

C Sharp :: Regular Expression To Find A Value In String

Apr 9, 2012

<IMG border=0 alt="UserDeviceId = 70813215">

Above is the sample string object from this i need to find the integer value of UserDeviceId.

View 2 Replies View Related

C :: Find Number Of Capital Letters And Punctuations In A String

Jan 28, 2015

write a C program which repeatedly reads in sentences from the user and reports on how many capital letters are in the sentence and how many punctuation characters. Your program will stop asking for input once the user has entered in a blank line. Consider the following example usage with the program. User input is marked in underline:

Enter a sentence: John and Mary went to Fred's house.
You used 3 capital letters and 2 punctuation characters.
Enter a sentence: I like A&W more than McDonald's.
You used 5 capital letters and 3 punctuation characters.
Enter a sentence:
Good bye!

Hint: make use of the standard C functions ispunct and isupper. Other requirements. You must make two functions.

Make a function called find_characters, which has a return type of void, and which has three parameters: one of type char * (a string to find characters in), one of type int * (a reference to int variable indicating how many capital letters are in the string) and the last one also of type int * (a reference to an int variable indicating how many punctuation characters are in the string). Your find_characters function should scan the string and update the two variables it has references to.Make a main function.

This function should repeatedly read in a string from the user, call your find_characters function, and output the information returned to it by the find_characters function indicating how many capital letters and how many punctuation characters were in the string. Your main function should stop reading in input when the user enters in a blank string (i.e., the user just hits enter without entering anything else in). You may assume that the user will not enter in a sentence longer than 100 characters

Code:
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
#include<string.h>

int main(void) {

[Code] .....

View 9 Replies View Related

C++ :: Find Adjacent Same Letter In Randomly Generated String?

Jan 29, 2013

I need a simple adjacent_find() to find the adjacent same letter in a randomly generated string?

View 1 Replies View Related

C++ :: String Find And Replace (Modified To Upper Case)

Feb 3, 2013

"C++ is a general-purpose programming language." I have to find the word "C++" and replace it with "Java" and then capitalize all letters.

#include <iostream>
#include <string>
using namespace std;
int main( ) {
string origin; //contains input string
string replace; //the string obtained by replacing "C++" with "Java"

[Code] ....

View 1 Replies View Related

C++ :: Given A String How To Find Longest Substring With All Unique Characters

Feb 9, 2015

I am new to C++ programming, writing a program for the below question:

given a string, how to find the longest substring with all unique characters.

View 1 Replies View Related

C++ :: Find Index Of String Array - Get Wrong Return Value?

Apr 17, 2014

Here is my code to find the index of a string array whose string is equal to the query string. I have checked the program can return the correct index, but the cout result is totally wrong.

#include <iostream>
#include <string>
using namespace std;

[Code].....

View 4 Replies View Related







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