48,986 Topics

Member Avatar for
Member Avatar for Joemeister

I want to know how I can do this: 1. Find "sqrt" in a string 2. Replace "sqrt" with only "#" I have the following code but its not working. Why? size_t found = 0; found = modifiedExpr.find("sqrt"); if(found!=std::string::npos) { modifiedExpr.replace(modifiedExpr.find(sqrt),sqrt.length(),"#"); }

Member Avatar for L7Sqr
0
195
Member Avatar for Kris_3

Hi again, so guys I want to add some color to my text but all the explanations I find are some links to complicated ways of doing it with almost no explanation of the operators functions and so on. Could you show me an easy way to make for example …

Member Avatar for Kris_3
0
176
Member Avatar for Saboor880

Hello to all! I am using compiler Dev C++ but i am facing a problem in with it. Sometimes it happens that if i try to run one program , it displays the output of another program instead of required program. For example I have two programs named as "Pointer" …

Member Avatar for Schol-R-LEA
0
169
Member Avatar for Joemeister

Let me explain what I want to do: I want to change a expression like this: x * (2 + 3) - (y + 1) to this: 5 * (2 + 3) - (6 + 1) using this: instVar('x', 5); instVar('y', 6); The problem is I get the following output: …

Member Avatar for iamthwee
0
162
Member Avatar for chris99

I am trying to create a window with a custom background after playing with the different styles, to practice declarations and destroying objects for future reference. Whenever I try to compile the code I get the following errors: "undefined reference to CreateSolidBrush@4" and "undefined reference to DestroyObject@4". Where in my …

Member Avatar for chris99
0
238
Member Avatar for singersongrita

I learned how you can use the switch statement to make the program go through the stuff inside and choose the one that matches the condition set. Isnt that basically what "if" statements do? so does this mean we can completely replace 'if' with 'switch'? because it seems way more …

Member Avatar for happygeek
0
153
Member Avatar for Jack_9

Is C++ worth learning for webapps? I know python and it works well, so would it even be worth it to learn c++?

Member Avatar for Jack_9
0
157
Member Avatar for DavidB

For the past while, I have gotten comfortable doing things a particular way when it comes to inputting data: i) create text file whose first entry is N, an integer indicating the number of data entries following, and the actual data entries. For example, for 101 data values, the text …

Member Avatar for DavidB
0
3K
Member Avatar for Joemeister

I am getting errors when I'm trying the following: instantiateVariable(string startingExpr, char var_, int val_) { int sizeArray = startingExpr.length(); //Convert the int into a char/string int number = val_; string newChar = ""; ostringstream temp; temp << val_; newChar = temp.str(); //Searching for the variable in the array for(int …

Member Avatar for iamthwee
0
295
Member Avatar for rela

I have to do my project using C++, should I firstly read a book about that and after that write the programming, or it's better to start wtiring my code and solve my problems and questions at the same time?

Member Avatar for NathanOliver
0
189
Member Avatar for exoruel

You pros are once newbies like us. Hoped you might take a little time sharing your expertise. Got freaked out when our teacher gave us this activity, where she haven't taught this to us yet. So this is the activity (LOOPING) : Write a program that accepts a positive integer. …

Member Avatar for exoruel
0
200
Member Avatar for Sinz_1

- When i'm trying to delete the first number of list, something went wrong when i print the list? - Can anyone help me? Thanks so much T_T. - Here my code: #include <stdio.h> #include <conio.h> #include <stdlib.h> struct node { int inf; node *next; }; node *insert_head(node *first, int …

Member Avatar for Schol-R-LEA
0
213
Member Avatar for Joemeister

Hello all, I am getting 3 errors when I try to use stacks when I want to evaluate a postfix expression. I am not very experienced with the usage of stacks so please be patient with me. Here is my code: //The postfix parameter is a postfix string that was …

Member Avatar for iamthwee
0
327
Member Avatar for Raaavennn

Hi please help me, im trying to make a program that only accepts numbers. What can I do to disable letters and special symbols? for example, I enter "sffsdttsfsjfs" / "!%#^$*$(" then the program would prompt that "Error: Letters and Special Symbols are not allowed" I saw a thread here, …

Member Avatar for David W
0
183
Member Avatar for Kris_3

So I just started using the Goto command and I have some trouble with it. I will post my code and explain the problem. cout<<"So here we are at your first choice."<<endl; cout<<"-Do you 'stand' there and TRY to get me out of your head..."<<endl; cout<<"Or do you 'follow' the …

Member Avatar for mike_2000_17
0
199
Member Avatar for Yahia Farghaly

hi all, while i am learning the overloading operators ,i studied the following syntax ostream&operator<<(ostream &, classname&); i understand how it works but only something that i don't understand is the use of (&) with ofstream class ?at this point what's happening ? also i notice that i can do …

Member Avatar for Moschops
0
426
Member Avatar for Yahia Farghaly

Hi all, for the code shown below , every thing is okey except few things i output the obj[i](sure the [] is overloaded) with the overloaded << but inside the operator definition i was outputing the m data member of the reference object,how ever it also outputs the m data …

Member Avatar for David W
0
172
Member Avatar for Jjajangmyeon

Nothing special - I just need to grab a line and slap it into a string - if(found == 1) { cout << "\n\n Please enter a new location for this event: \n"; getline(cin,newAct); cout << "New Account: " << newAct << endl; } else { cout << "\nEvent not …

Member Avatar for vijayan121
0
179
Member Avatar for Jjajangmyeon

I'm new to using vectors, and I'm trying to declare a vector with size 1: vector<string> activities(1); I get an error with this code, can anyone explain why? G:\ManageActivities\Activity.h|11|error: expected identifier before numeric constant| G:\ManageActivities\Activity.h|11|error: expected ',' or '...' before numeric constant|

Member Avatar for vijayan121
0
300
Member Avatar for nathan.pavlovsky

Is it poor convention to create a c++ file only to store various functions, and then include it into the main.cpp? This would be done so that the functions could be used in different programs as well.

Member Avatar for nathan.pavlovsky
0
454
Member Avatar for Kris_3

Hi guys so I am still learning and there might be an easier way to do thing than how i do them but still i need some help. So I was thinking of making a program in which it asks you a question , lets say Yes/No question and you …

Member Avatar for Kris_3
0
132
Member Avatar for aluhnev

class Animal { string _name; string _type; string _sound; // private constructor prevents construction of base class Animal(){}; protected: // protected constructor for use by derived classes Animal(const string & n, const string & t, const string & s) : _name(n), _type(t), _sound(s) {} public: void speak() const; const string …

Member Avatar for NathanOliver
0
221
Member Avatar for Jsplinter

I do not understand what the following code does: enum testEnum: unsigned char { FOO_ENUM, BAR_ENUM }; unsigned char sideFilter1 = 1 << FOO_ENUM; unsigned char sideFilter2 = (1 << FOO_ENUM) | (1 << BAR_ENUM);

Member Avatar for NathanOliver
0
182
Member Avatar for amithunter

Actually i am confused with concept of database conectivity in c++ with any traditional Dbase server is it possible if yes then how....pls help Thanks for the help in advance

Member Avatar for rubberman
0
205
Member Avatar for Katangka

Hello! I've seen a thousand dicsussion about how to make an .exe file from your .cpp source code, but none of it seems to help me: since I have the .exe file, I just can't run it on any other computer. Can anybody help me out, what libraries should I …

Member Avatar for misi
1
10K
Member Avatar for Otani

Hello, I'm a beginner in this site. I was just hoping that someone might be able to answer my question regarding to debugging a payroll. Here: #include <iostream> #include <conio.h> #include <string> #include <windows.h> #include <stdio.h> using namespace std; const string userName= "Username"; //assigns the username const string passWord= "Password"; …

Member Avatar for Otani
0
765
Member Avatar for Kris_3

Hey guys. So I have made a little project but I want to give it to a friend to test it out. I am using Code::Blocks and I want to save the file so that when you click it it comes out like the window I get when I run …

Member Avatar for Kris_3
0
123
Member Avatar for Kris_3

Hi guys , so I just started learning C++ so I am trying to do something but id does not turn out quite how I want it to be. So my idea is to create a text game and I'm at the very beggining and I have a lot of …

Member Avatar for Kris_3
0
214
Member Avatar for new_developer

Hi there, I need explanation for the range of data type say character which is 1byte ranges from -127 to 127 or 0 to 255. I did not understand what it means and how can I check the range of characters. Does it means it can store only values from …

Member Avatar for Slavi
0
259
Member Avatar for kamalashraf

hi, below is the code for binary search in case of array is sorted in ascending order. what changes i have to do if array is sorted in descending order. #include<iostream> using namespace std; void getdata (int a[], int size); int binarysearch (int a[], int size, int key); int main() …

Member Avatar for rubberman
0
7K

The End.