Forum: C++ Jul 13th, 2009 |
| Replies: 9 Views: 390 try
void* type = (void*)this;
std::vector<void*> |
Forum: C++ Mar 11th, 2009 |
| Replies: 8 Views: 419 change
*vendorName != 'q' || *vendorName != 'Q'
to
vendorName[0] != 'q' && vendorName[0] != 'Q' |
Forum: C++ Oct 28th, 2008 |
| Replies: 4 Views: 369 #include <iostream>
#include <algorithm>
using namespace std;
#define MAX_NUMBERS 5
int main() {
int input_numbers[MAX_NUMBERS];
for(size_t i = 0; i < MAX_NUMBERS; ++i){
cout << "Enter... |
Forum: C++ Oct 28th, 2008 |
| Replies: 4 Views: 369 http://www.cplusplus.com/reference/algorithm/min_element.html |
Forum: C++ Oct 25th, 2008 |
| Replies: 5 Views: 419 change
printf("%d",d);
to
printf("%s", d.c_str()); |
Forum: C++ Oct 18th, 2008 |
| Replies: 3 Views: 383 or may be your code look like this
void foo()
{
char* tmp = new char[1024];
foo();
} |
Forum: C++ Oct 7th, 2008 |
| Replies: 4 Views: 443 remove this line
_cptPoints = new CPt [++_iSize]; |
Forum: C++ Oct 1st, 2008 |
| Replies: 33 Views: 2,855 is now ok :}
#include <iostream>
int stripspaces(char str[]);
using namespace std;
int main() {
char ar[100]; |
Forum: C++ Oct 1st, 2008 |
| Replies: 1 Views: 404 so... is this work for you?
#include <iostream>
#include <fstream>
using namespace std;
struct color {
unsigned char blue;
unsigned char green;
unsigned char red; |
Forum: C++ Oct 1st, 2008 |
| Replies: 33 Views: 2,855 #include <iostream>
int stripspaces(char str[]);
using namespace std;
int main() {
char ar[100];
cout << "Enter a sentence and I will strip out the spaces:" << endl; |
Forum: C++ Oct 1st, 2008 |
| Replies: 12 Views: 822 you can swap two ints with x^=y^=x^=y;
edit: btw you can use #define max(x,y) (((x) < (y)) ? (y):(x)) :D |
Forum: C++ Sep 30th, 2008 |
| Replies: 12 Views: 822 #include <iostream>
using namespace std;
int min(int x, int y) {
return x < y ? x : y;
}
int max(int x, int y) {
return x > y ? x : y;
}
int sumTo(int, int); |
Forum: C++ Sep 30th, 2008 |
| Replies: 5 Views: 1,235 int x;
sscanf(str,"%*c%*d%*c%d", &x); |
Forum: C++ Sep 30th, 2008 |
| Replies: 4 Views: 769 void lol(hash_map<string, wordStruct>& hashofwords){
...
}
int main(){
...
lol(hashofwords);
...
return 0;
} |
Forum: C++ Sep 30th, 2008 |
| Replies: 7 Views: 585 #include <iostream>
#include <fstream>
using namespace std;
int main() {
string op;
int val1;
int val2;
string val3; |
Forum: C++ Sep 29th, 2008 |
| Replies: 14 Views: 2,272 #include <iostream>
#include <sstream>
#include <string>
using namespace std;
void print_int(int number){
stringstream tmp_stream;
tmp_stream << number;
string str_num(tmp_stream.str());... |
Forum: C++ Sep 15th, 2008 |
| Replies: 21 Views: 2,590 add std::sort or don't use vector :P
#include <iostream>
using namespace std;
int main(int argc, char **argv) {
double num[10];
for (int i = 0; i < 10; ++i) {
cin >> num[i];
} |
Forum: C++ Sep 14th, 2008 |
| Replies: 12 Views: 795 line: 328 - you need operator[]
line: 338 - you must return istream&
line: 371 - you don't need "friend" key word
line: 365 - &artist[0]??? what is this... you have 2 options: 1. make copy... |
Forum: C++ Sep 14th, 2008 |
| Replies: 21 Views: 2,590 #include <iostream>
#include <vector>
using namespace std;
int main(int argc, char **argv) {
vector<double> num;
vector<double>::iterator it;
for (int i = 0; i < 10; ++i) {
double tmp;... |
Forum: C++ Aug 5th, 2008 |
| Replies: 16 Views: 2,646 so if you have address of int - you can try this :)
int * money = (int*)0x7ffd8000;
*money = 666; |
Forum: C++ Aug 1st, 2008 |
| Replies: 9 Views: 752 use vector::size(), not vector::capacity() |
Forum: C++ Jul 31st, 2008 |
| Replies: 4 Views: 637 element_t* buffer_end = &buf[length-1];
btw. this is not working on VS2008
// &*container.begin() gets us a pointer to the first element
but it work on gcc :P |
Forum: C++ Jul 31st, 2008 |
| Replies: 9 Views: 752 yes, but you can try using std::vector ;) |
Forum: C++ Jul 31st, 2008 |
| Replies: 9 Views: 752 mySuper->mySub = mySub;
delete mySub;
mySuper->mySubCount++;
}
else
{
mySuper->mySub = new Sub[1];
mySuper->mySubCount = 1;
} |
Forum: C++ Jul 30th, 2008 |
| Replies: 9 Views: 752 one problem:
int* x = new int; //ok
delete x; //ok
but
int* x = new int;
int* y = x;
delete x; |
Forum: C++ Jul 26th, 2008 |
| Replies: 6 Views: 1,521 you can reverse using std::reverse :}
std::reverse(string.begin(), string.end()); |
Forum: C++ Jul 25th, 2008 |
| Replies: 1 Views: 503 #include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
int main()
{
ifstream ifs1("data1.txt");
vector<string> data1;
if (ifs1.is_open()){ |
Forum: C++ Jul 25th, 2008 |
| Replies: 4 Views: 703 #include <iostream>
#include <fstream>
#include <string>
#include <vector>
using namespace std;
class ClientData
{
public: |
Forum: C++ Jul 23rd, 2008 |
| Replies: 4 Views: 703 you can't use read() because:
in text file "1 Bob 100" = string
so 1 = char, but your class need int
and ' ' = char too, but your class dont need it
#include <iostream>
using std::cout;
using... |
Forum: C++ Jul 22nd, 2008 |
| Replies: 1 Views: 372 my fix so far... still unplayable, but i need some rest.
#include <cstdio>
#include <ctime>
#include <iostream>
#include <windows.h>
#include <fstream>
#include <vector>
using namespace std; |
Forum: C++ Jul 22nd, 2008 |
| Replies: 6 Views: 1,513 here is my code, i know it is not what you ask, but i have fun to wright it.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void read_lines(fstream& file, int&... |
Forum: C++ Jul 22nd, 2008 |
| Replies: 3 Views: 444 #include <string>
#include <fstream> |
Forum: C++ Jul 22nd, 2008 |
| Replies: 14 Views: 6,528 |
Forum: C++ Jul 21st, 2008 |
| Replies: 3 Views: 444 string dir_name;
getline(cin, dir_name);
ifstream file(dir_name.c_str()); |
Forum: C++ Jul 21st, 2008 |
| Replies: 4 Views: 446 string num1 = "1234";
string num2 = "4567";
string sum = "";
char tmp2 = 0;
1. reverse num1 and num2
2. for 0 to string size() do
char tmp = num1[i] + num2[i] + tmp2;
tmp2 = 0;
if (tmp >... |
Forum: C++ Jul 21st, 2008 |
| Replies: 3 Views: 415 int& sumz(int x,int y)
{
int *sum = new int;
*sum = x + y;
return *sum;
} |
Forum: C++ Jul 21st, 2008 |
| Replies: 4 Views: 446 using std::string and operator overloading, yes it is able |
Forum: C++ Jul 17th, 2008 |
| Replies: 4 Views: 408 here is the fix for save game, problem was in save game function....
#include<iostream.h>
#include<fstream>
#include<string>
using namespace std;
char choice;
int missionNumber = 0;
int... |
Forum: C++ Jul 17th, 2008 |
| Replies: 4 Views: 1,322 hm.. why free dos? there is hm... what was name....... linux? |
Forum: C++ Jul 17th, 2008 |
| Replies: 5 Views: 540 |