C :: Function To Search If Two Given Strings Are Equal
Jul 9, 2014
I made my own function to search if two given strings in my function are equal but the problem is if i pass two variable like hello,hello ... result is string equal but if i pass hello , hello also give me string equal because last 4 characters same to last 4 characters of hello ...
Code:
int getSimilarityOfTwoStrings(const char str1[],const char str2[]){
int str1Len = getStringLength(str1);
int str2Len = getStringLength(str2);
int i = 0;
int j = 0;
bool truefalse;
[Code] .....
View 3 Replies
ADVERTISEMENT
Nov 22, 2013
How could I search a vector element with multiple strings
i.e. vector.at(i) = This is a test
How could I search that to look for the word "test" in that element?
View 7 Replies
View Related
Feb 4, 2013
The function should search the array of strings to find how many times the word 'the' was used. but its only returning a 0.
int FindThe (int The, char Paragraph[], char Pattern[]) {
for (int i(0); i < 500; i++) {
if (Paragraph[i] == Pattern[0] {
[Code] ....
View 5 Replies
View Related
Jun 8, 2014
I need to develop a simple program, i have 2 variables (begin, end), and i need to search in a file, And extract the string between the Begin and the End variables to a new File, For Example:
my text file: file.txt:
some text here<StartHere>more text here</EndHere>text text
C++ Program:
//Declear 2 variables
strcpy_s(begin, string("<StartHere>").c_str());
strcpy_s(end, string("</EndHere>").c_str());
//And now, search in the Text file, And Extract the text between the begin string and the End string.
<...>
The Result should be: NewFile.txt with the content:
<StartHere>more text here</EndHere>
That's it!, Here is what i have for now:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
int main() {
int ocurrences_count = 0;
int ocurrences2_count = 0;
char word[20]; //this array will save user input
[Code] ....
View 1 Replies
View Related
Sep 25, 2012
I'm trying to do a binary search on a vector of strings and keep getting this error. This is the PhoneEntry header file with the class declaration:
Code:
using namespace std;
#include<string>
#include<iostream>
#include<fstream>
#include<vector>
#include"phoneNumber.h"
[Code] .....
View 5 Replies
View Related
Apr 4, 2013
#include <iostream>
#include <cwchar>
#include <string>
#include <Windows.h>
using namespace std;
#include <shellapi.h>
#pragma comment(lib,"shell32.lib")
static HWND hBut;
#define ShellExecute;
[Code] ....
My function is the issue. I'm not sure how to write a correct function to search your computer for file 'a'.
View 3 Replies
View Related
Nov 26, 2013
I am having an issue when i try to delete a node with 2 children it either doesn't delete anything, or wigs out in various manners deleting the wrong node or replacing a node with a various memory location. As follows, here is the delete function:
void BST::dele(){
bool found = false;//initialize a bool type to "find" the element to be deleted
if(root == NULL) return;//well if the tree's empty, nothing to be found right?
current = root;//set the current to the root to traverse the tree in search of the element
node* parent;//create a parent node for use once the node has been deleted
while(current != NULL){//traverse the tree
[Code] .....
View 1 Replies
View Related
Sep 10, 2014
i would like to know how to replace a value with the variable that ii is equal, i mean like a=5 i want to be able to replace the number 5 by the letter a when needed in printf. ofc i want to use this for an actual purpuse and meaning what i gave was a mere example and thxx. BTW DONT jUst DROP a few lines of code that would make it work
View 5 Replies
View Related
Sep 23, 2013
Code:
#include<stdio.h>
#include<string.h>
#define MAX 25
int main(void)
{
int ch;
[Code]....
i think that cause this program to be error.because when i using the reference from internet, the program was executed for sure.This code what i mean
Code:
#include <stdio.h>
#include <string.h>
#define MAX 10
int main () {
int ch;
char str[] ="This is a simple string";
char str1[MAX];
char str2[MAX];
[Code]....
and rather than that i didnt have anymore idea to make that replacing string.
View 6 Replies
View Related
Apr 1, 2014
I had an assignment that I completed and it was just inserting values into a binary tree and then displaying it. I was wondering what the code would be if I wanted to delete a number in the binary tree, or if I wanted to search for a number. Here is my code for my assignment.
Code:
#include <stdio.h>
#include<stdlib.h>
typedef struct bt_{
int value;
struct bt_ *right;
struct bt_ *left;
[Code] ....
View 1 Replies
View Related
Mar 19, 2013
I have a linkedList search function given and I am having a little trouble getting it to work. I've made a few attempts with no success. Given normal search code:
template <class Type>
bool orderedLinkedList<Type>::search(const Type& searchItem) const {
bool found = false;
nodeType<Type> *current; //pointer to traverse the list
current = first; //start the search at the first node
[Code] .....
My attempt to make it a recursive search:
template <class Type>
bool orderedLinkedList<Type>::search(const Type& searchItem) const {
//bool found = false;
nodeType<Type> *current; //pointer to traverse the list
current = first; //start the search at the first node
[Code] ....
View 3 Replies
View Related
Feb 14, 2014
Im working on a BST remove function. I think I'm on the right track but I'm not sure. From what I understand there are 3 possible cases. A Node with no children, one child, or 2 children(this being the most complex).
void BST::remove(int x) {
TreeNode *n;
TreeNode *v;
n= root;
while(n != NULL && n->key != x){
[Code] ....
View 4 Replies
View Related
Jan 15, 2015
I'm working on this program for homework an here is the problem:
Write a program that keeps track of a speakers bureau. The program should use a structure to store the following data about a speaker.
Name
Telephone Number
Speaking Topic
Fee required
The program should use an array of at least 10 structures.It should let the user enter data into the array, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface.
So I did the program which is below but now it is asking this:
Add a function that allows the user to search for a speaker on a particular topic. It should accept a key word as an argument and then search the array for a structure with that key word in the searching topic field. All structures that match should be displayed. If no structure matches, a message saying so should be displayed.
Now this where I get stuck, I'm having trouble figuring out how to write down the search function in this program. A function that can work and how to get it to match the topics listed by each speaker.
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
struct speakerBureau {
[Code] .....
View 4 Replies
View Related
Jun 21, 2013
I'm trying to add a search and delete function to my program
#include <Windows.h>
#include <stdio.h>
#include <string.h>
#include <string>
#include <iostream>
using namespace std;
class Cvampire{
[Code] ....
View 4 Replies
View Related
Nov 2, 2014
1) how come root node is printed when the first call to function goes to left subtree?
2) How it resets to root to go to right subtree from last left tree leaf?
void bst:: printNodes(hwareItem*& root){
if(root){
printNodes(root->left);
cout<<root->barcode<<endl;
cout<<root->description<<endl;
cout<<root->price_per_unit<<endl;
cout<<root->stock<<endl;
printNodes(root->right);}
}
View 19 Replies
View Related
Feb 9, 2014
I'm have troubles with this program that requires me to make a search through a Linked List and find a specified value. It also needs to be a template function. I've completed the rest of the program fine and everything runs ok except for the search function. Code below:
Linked.h
#ifndef LINKED_H
#define LINKED_H
#include<iostream>
template <class T>
class Linked {
[Code] ....
I have commented out my attempt at the search function. When uncommenting the function I get several errors about <template> being incorrect syntax.
View 8 Replies
View Related
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
Feb 9, 2014
The program I have below. If you copy and paste it it should work. However, When I uncomment my search function I get lots of errors and I think it has to do with incorrect syntax of it being a template. Need to do this search function:
Linked.h header file
Code:
#ifndef LINKED_H
#define LINKED_H
#include<iostream>
template <class T>
class Linked {
private:
// Declare a structure for the list
[Code] .....
View 2 Replies
View Related
Feb 3, 2015
How i can find two equal int in array with O(n) time complexityand O(1) place complexity?
View 8 Replies
View Related
Jan 21, 2014
I'm making a simple calculator and have done it all right where you can input everything, all the functions are there, but when i run the program it will come to displaying the result and it will always equal zero, I just need it to say 8+8 = 16 rather than 8+8 = 0, i don't know whether its just displaying the results as 0, or not displaying it at all, the code will follow below:
Code:
#include<iostream>
using namespace std;
double num3;
double num2;
double result;
char operation;
[Code] ....
View 4 Replies
View Related
Mar 21, 2013
creating a program using while that terminates the loop when two intergers any two between 1 to 100 are equal with each other
View 2 Replies
View Related
Mar 26, 2014
None of my string is coming out onto my output file..
void OutputHeading (ofstream& fout, string CLASS_EXERCISE,
string PROGRAMMERS_NAME);
void OutputDivider (ofstream& fout, int WIDTH,
char symbol);
void OpenFiles (ofstream& fout, ifstream& fin);
[Code] .....
View 1 Replies
View Related
Jun 5, 2013
Code:
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
struct node
{
int data;
struct node *next;
[Code] ....
It fills the singly-linked list with 0 through 9 and calls a function to prompt the user to search for a number. I don't see any glaring errors, I was just wondering what could be done to simplify it or if there's anything I missed.
View 8 Replies
View Related
Apr 5, 2013
I currently have a file which allows inputs to record different transistor types. I then have the task of accessing this structure, find a certain manufacturer ID, and print the information about this particular transistor.
My problem is accessing the array to search through.
Here is my code:
Code:
#include "stdio.h"
const int IDLEN=30; //All constant values defined
const int POLARITYLEN=3;
const int MAXSTOCKITEMS=10;
//First structure defined
struct TransistorRec {
[Code]......
The errors I am currently getting are on line 54 'expected primary-expression before "struct"' and on line 60 ' 'maunfacturersID' undeclared'
View 11 Replies
View Related
Jun 23, 2013
I was studying BST and tried to make a iterative function to insert, the original recursive function is the following:
void insert(node *&tree, int value) {
if (!tree) {
tree = new node;
tree->num = value;
tree->left = tree->right = NULL;
[Code] ....
And the code that i did is (but doesn't work):
void insert(node *&tree, int value) {
if (!tree) {
tree = new node;
tree->num = value;
tree->left = tree->right = NULL;
[Code] ....
I don't see where the error is or why it doesn't work.
View 6 Replies
View Related
Oct 28, 2013
I'm trying to make a program that will search for a line in a text file using a non default delimitor at the start of the line. An example line in the text file would be as follows:
F Mary Smyth, 19, United Kingdom
I have been able to use the find function to search for and return the 'F' character but would like it to then display the whole corresponding line. Is this possible with the find function?
ifstream readFromFile("data.txt");
string Destinations[1] = {"F "};
string data;
while(!readFromFile.eof()){
getline(readFromFile,data);
[code]...
View 2 Replies
View Related