48,986 Topics
| |
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(),"#"); } | |
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 … | |
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" … | |
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: … | |
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 … | |
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 … | |
Is C++ worth learning for webapps? I know python and it works well, so would it even be worth it to learn c++? | |
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 … | |
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 … | |
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? | |
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. … | |
- 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 … | |
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 … | |
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, … | |
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 … | |
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 … | |
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 … | |
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 … | |
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| | |
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. | |
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 … | |
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 … | |
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); | |
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 | |
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 … | |
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"; … | |
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 … | |
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 … | |
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 … | |
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() … |
The End.