Hi
I want to create a for loop, that would compare two sets numbers in each iteration and return either 1 if the first number is bigger then the second or 0 if it's the opposite. This I have already done. Then I want to store these numbers in one string so the final string would look like this 01101101010011. I am unable to find a way to create such code that would append one number each iteration to the string.
Thanks in advance
string global_string;
int checker(int first, int second) {
global_string.push_back(first); //push_back() inserts something into the end of a vector (strings are a vector of chr)
global_string.push_back(second);
if(first > second) {
global_string.push_back(1);
return 1;
} elseif (second > first) {
global_string.push_back(0);
return 0;
} else {
return -1; //strings match...don't know what you want to do there...
}
}
You would have to incorporate this into your loop, since I do not know what you are iterating through.
Thanks for help, but it doesn't work and I have no idea why...
The compiler says
error C2039: 'push_back' : is not a member of 'basic_string<char,struct std::char_traits<char>,class std::allocator<char> >'
I have all these includes in my code and I think <string> should cover this, so I don't know why it isn't working.
#include <iostream>
#include <string>
#include <fstream>
#include <conio.h>
#include <math.h>
Yeah I figured that out when I was browsing other string functions and they didn't work either. I'm downloading VS 2008 pro trial from MS site, hope it will work there.
error all the time while build is in process. The exe of my program is created, so I can use it, but still this should be fixed somehow I guess. I think it is connected with the manifest, but I have no idea what it is used for.
Visual Studio 2008 doesn't seem to have stdafx.h. In fact, I can't even use _tmain(). I can change _TCHAR* to TCHAR* and #include <windows.h>, but that still leaves an error where _tmain() is undefined according to the linker.
To get around this, you need to #include <tchar.h> instead. That should fix that last program.
@Kvakac
I have seen this sort of problem in the past (I think is was with VS2005), I'm trying to remember how it was resolved, what is coming to mind at the moment is the old faithful re-install or posibaly checking the path variables of windows and VS.
@rpgfan3233
stdafx.h is created by the prject wizard, it has the windows.h... includes in it.
@rpgfan3233
The error that Kvakac is having "error PRJ0003 : Error spawning 'mt.exe'" is nothing to do with the precompiled header. The reason I asked if there was a problem with a new project was to see if the conversion of a VC6 project was at fault.
Yes that is the case, it produces this error regardless of the code. It must have something to do with the manifest. Could it be that I have only trial version of MSVS 2008 ?
Anyway the program is created normally so it only bothers me a bit.
I've uninstalled the 2008 pro trial and downloaded 2008 express edition to check if it isn't something in my system and it works fine there , no problems with embedding manifests or anything else. Maybe the installation files were corrupt, I don't know. I guess this express edition will be sufficient for my needs.
Anyway, thanks for help everyone