How to make function return string in c++
Possible Duplicate: How to convert this code to use string I have a function like this: char *foo() { } How can I make it return a string instead? I tried string foo() { } but the compiler complains. ...
Possible Duplicate: How to convert this code to use string I have a function like this: char *foo() { } How can I make it return a string instead? I tried string foo() { } but the compiler complains. ...
Hi! Does anybody know if/how I can read from the callstack from a specific address? suppose I have a offset address from the base address of the callstack, how can I get the base address? thanks :) ...
I recently read Eric Steven Raymond's article "How To Become A Hacker" and I like his suggestion of learning 5 key languages (he suggests Python, C/C++, Lisp, Java, and Perl) as a way of covering the main programming paradigms in use today. His advice is that it's not so important which specific languages a programmer knows. It's more ...
what is the difference between friend function and friend class? and where should be use of friend keyword? ...
void print_combinations(const std::string &str) { int i, j, k; int len = str.length(); for (i = 0; i < len - 2; i++) { for (j = i + 1; j < len - 1; j++) { for (k = j + 1; k < len; k++) // show combination ...
i have following code #include <iostream> using namespace std; int reverse(int n) { int m=0; while (n>0) { m*=10; m+=n%10; n/=10; } return m; } int main() { int n=97; cout<<reverse(n)<<endl; return 0; } when i run this code program says access is denied why? ...
Possible Duplicate: Inline functions vs Preprocessor macros what is the use of inline function and how it works? Are inline and macro different? ...
This is the statement from ISO C++ Standard 14.6.2.4: Dependent template arguments : A type template-argument is dependent if the type it specifies is dependent. An integral non-type template-argument is dependent if the constant expression it specifies is value dependent. A non-integral non-type template-argument...
c:\program files\microsoft visual studio 9.0\vc\include\result.h(212) : warning C4275: non dll-interface class 'std::_Container_base_aux' used as base for dll-interface class 'std::_Container_base_aux_alloc_real<_Alloc>' 1> with 1> [ 1> _Alloc=std::allocator<mysqlpp::Row> 1> ] 1> C:\Program Files\Mi...
Okay so I was board and wondered how fast math.h square root was in comparison to the one with the magic number in it (made famous by Quake but made by SGI). But this has ended up in a world of hurt for me. I first tried this on the Mac where the math.h would win hands down every time then on Windows where the magic number always won, ...
#include <iostream> using namespace std; void f(int x, int y){ cout << "x is " << x << endl; cout << "y is " << y << endl; } int main(){ int i = 7; f(i--,i-- ); cout << i << endl<< endl; } We expected the program to print "x is 7 \n y is 6 \n i is 5" but the program printed "x is 6 \n y i...
Here is the code, int array[X][Y] = {0,}; // 1 way to access the data for (int x = 0; x < X; x++) for(int y = 0; y < Y; y++) array[x][y] = compute(); // the other way to access the data for (int y = 0; y < Y; y++) for (int x = 0; x < X; x++) array[x][y] = compute(); Is it true that the first way is more efficient than th...
Hi guys, total noob here with about 2 months of C++ experience (no other background) so go easy on me. I am writing a battleship game for a programming assignment. The game grid is 15X20 and I am trying to have the grid as a private member variable of the class player. My question is: If the class player has a private member variab...
Whilst building unit tests for a client/server system at work, I ran into a problem where my io_service was not releasing after I had shutdown all the active handlers (that I was aware of). After a day of trawling through code, I came across the errant handler which had not been integrated into my client shutdown procedures. My questio...
I am writing a program that needs to run a set of executables and find their execution times. My first approach was just to run a process, start a timer and see the difference between the start time and the moment when process returns exit value. Unfortunately, this program will not run on the dedicated machine so many other processes ...
In C++, what is the standard way to remove the command prompt, without using WinMain()? This is hopefully a simple question. I am using MSVC. ...
In this example, employee structs are parsed in the form "employee{int, string, string, double}". I would like to know whether it is possible to modify this example to also parse different types of structs, like "intern{int, string, string}". Specifically, I would like to then pass the structure to a function overloaded on the structur...
I want to replace all the occurances of ' in a string to ^, but i saw string.replace is not the right function for me, do I need to write my own? It's boring. ...
What is the difference between int* i and int** i? ...
stack <char> stck; string str; stck.push('0'); str.append("test:"); //test: cout << str << endl; str.append(&stck.top()); //test:0═══════════════¤¤¤¤▌▌▌▌,╘╥XЕ┤ cout << str << endl; Why is this happening? ...