921 Posted Topics

Member Avatar for wellibedamned

If all your trying to do is sort [B]int's[/B] / [B]floats[/B] you are doing it the hard way, all you have to do is convert each string you input to a float and then sort them. So you can delete the other two functions ([B]lrg[/B], [B]posd[/B]). Something thing you should …

Member Avatar for wellibedamned
0
211
Member Avatar for Alex Edwards

Well, dynamically allocating space is much slower than stack and the life of a dynamic variable is dependant on when you decide to delete it, however stack variables are deleted at the end of the code block.

Member Avatar for Alex Edwards
0
217
Member Avatar for William Hemsworth

Hi I have a small question, probably quite obvious but I cant seem to figure it out. When using the ifstream or any other stream you can tell if it was sucessfull in its last event. For example: [CODE=CPP] #include<fstream> int main() { ifstream in("test.txt", ios::in); if (in) { } …

Member Avatar for William Hemsworth
0
110
Member Avatar for Extremus

I learned how to do Win32 programming quite well in under a week off this tutorial, it might be what your looking for. You should also do this tutorial before moving on to MFC, it will help. [url]http://www.winprog.org/tutorial/start.html[/url]

Member Avatar for Ancient Dragon
0
134
Member Avatar for asianguyjtran

I think you need to disable unicode to remove those errors. Try adding: [CODE]#undef UNICODE[/CODE] at the very beginning of your source code.

Member Avatar for asianguyjtran
0
100
Member Avatar for joshuabraham
Member Avatar for William Hemsworth

Hi I am trying to make function which returns a substring as a [ICODE]char*[/ICODE], but [ICODE]string::substr[/ICODE] returns a [ICODE]const char*[/ICODE]. So I have managed to make a function that will return a substring as [ICODE]char*[/ICODE], except when I was comparing the speed of the two, I found that [ICODE]string::substr[/ICODE] was …

Member Avatar for William Hemsworth
0
277
Member Avatar for Math.C

You havent explained your problem. I can see a few errors just by looking at it. [LIST] [*][ICODE]BaseArea (i,x,y,z);[/ICODE] [B]i[/B] hasnt been assigned a value yet [*]Change <iostream.h> to <iostream> [*]Your using std events but you fergot to add [ICODE]using namespace std;[/ICODE] at the beginning of the code [/LIST] [B]<iostream.h> …

Member Avatar for Ancient Dragon
0
99
Member Avatar for Flixter

Many problems in the code.. but this will remove the error: [CODE] #include <iostream> #include <vector> using namespace std; class Pair { public: Pair(int a, int b) {x=a; y=b;}; int get_x() {return x;}; int get_y() {return y;}; private: int x; int y;}; int main() {[COLOR="Red"]vector<Pair> set;[/COLOR] Pair* a1 = new …

Member Avatar for Flixter
0
151
Member Avatar for brk235

Yes, what Ancient Dragon sead will work fine, to save some time you could define it as a macro. [CODE] #include<iostream> #define rand_f(n) (((rand()%10000)/10000.0f)*n) int main() { for (int i = 0; i < 100; i++) { std::cout << rand_f(1) << '\n'; } std::cin.ignore(); return 0; } [/CODE]

Member Avatar for William Hemsworth
0
116
Member Avatar for phalaris_trip

I dont often use goto, but it has been usefull in some cases for me too. There might be better ways to do this but this seems like the easiest method to me: [CODE=CPP] // Breaking out of nested loops for (int i = 0; i < 100; i++) { …

Member Avatar for Duoas
0
274
Member Avatar for Black Magic

No way.., the moniter doesn't communicate with the PC in any way, except by recieving information for it to display.

Member Avatar for Duoas
0
121
Member Avatar for purepecha
Member Avatar for Gagless

This will return true if the characters are equal up to the minimum length of the two strings. And it does not use the == operator. [CODE] bool Compare(char *str1, char *str2) { if (!(*str1 || *str2)) return true; // End of string bool match = (*str1 >= *str2) && …

Member Avatar for William Hemsworth
0
1K
Member Avatar for Black Magic

To make rand() generate a random number inbetween a certain value you need to do something like this: [CODE] int var = rand() % 100; // Generates a random number between 0 and 100 [/CODE] But every time you load the program up you should first call srand(time(NULL));

Member Avatar for Salem
0
101
Member Avatar for Kadence

I think you need to learn how to use pointers. Heres a tutorial: You probably only need to look at the [B]Pointer initialization[/B] section. [url]http://www.cplusplus.com/doc/tutorial/pointers.html[/url]

Member Avatar for Salem
0
204
Member Avatar for Talianika

Very easy to do, heres an example: [CODE] #include<iostream> using namespace std; int main() { cout << "Enter maximum value: "; int max; cin >> max; // int sum = 0; // old1 + old2 int old1 = 0; // old int old2 = 1; // oldest // while (sum …

Member Avatar for wellibedamned
0
121
Member Avatar for wellibedamned

[QUOTE] you cant have a single array of floats "mixed with" ints [/QUOTE] You can have an array with different data types, you just need to point to them using void* example: [CODE] void *array[] = {(int*)123, (char*)"Hello"}; cout << (int)array[0]; // prints 123 cout << (char*)array[1]; // prints "Hello" …

Member Avatar for jephthah
0
152
Member Avatar for savinki

I just happened to have posted in a thread very similar to this. [url]http://www.daniweb.com/forums/thread107523.html[/url] Heres a few functions that may help. [CODE] #include<iostream> using namespace std; inline char *SubStr(char *text, int beg, int end) { register unsigned len = end - beg; register char *cut = new char[len]; memcpy_s(cut,(rsize_t)len,&text[beg],(size_t)len); cut[len] …

Member Avatar for saandeep_jan
0
1K
Member Avatar for Anita Jennifer
Member Avatar for Anita Jennifer
0
100
Member Avatar for jrkeller27

This may not be the best way to seperate each word, but heres how I managed it. You could read all the text out of the file first and then manually retrieve each word. [CODE] #include<iostream> using namespace std; #pragma warning(disable : 4018) char *SubStr(char *text, int beg, int end) …

Member Avatar for William Hemsworth
0
1K
Member Avatar for cobaltbass
Member Avatar for Duoas
0
283
Member Avatar for Black Magic

Try this: [CODE] #include <iostream> using namespace std; int main() { unsigned int digit1; unsigned int digit2; for( digit1 = 0; digit1 < 10; digit1++ ) { for( digit2 = 0; digit2 < digit1 + 1; digit2++ ) { cout << '*'; } cout << '\n'; } cin.get(); return 0; …

Member Avatar for William Hemsworth
0
101
Member Avatar for Lukezzz

The other computer you are testing it on probably does have the required .NET framework to execute the program.

Member Avatar for Lukezzz
0
122
Member Avatar for William Hemsworth

Hello I have a friend who has a problem with his PC, as soon as he turns his computer on it will get stuck at the loading screen. The last line is displays is: [B]Press F1 for setup...[/B] He has the same problem before but it would continue normally after …

0
62
Member Avatar for marcelomdsc

For C you can use these functions: [CODE] #include<iostream> using namespace std; typedef unsigned char UCHAR; template<class t> inline char *toBase(t val, char base, char *values) { register char d = 1; t c; register bool _signed = val < 0; if (val >= 0) for (c = base; c …

Member Avatar for marcelomdsc
0
100
Member Avatar for savinki
Member Avatar for manzoor

Heres a way of doing it without < > <= >= [CODE] #include<iostream> using namespace std; int min3(int a, int b, int c) { for (int i = 0;; i++) { if (i == a) return a; if (i == b) return b; if (i == c) return c; } …

Member Avatar for William Hemsworth
0
103
Member Avatar for ro4782

Here is a way to do it, I made a function [B]GetWord[/B] which will return a word depending on the index and the gaps you give it. It will loop through all the words and count number of words that match. Hope it helps. [CODE] #include<iostream> using namespace std; inline …

Member Avatar for William Hemsworth
0
101
Member Avatar for 3m4d
Member Avatar for hammerhead
0
369
Member Avatar for Black Magic

Do you meen actually emulating keypresses ? Here is an example of how to do that: [CODE] #include<iostream> #include<windows.h> using namespace std; void SendKeysWait(char *text, int interval); int main() { system("start C:\\Windows\\notepad.exe"); Sleep(1000); SendKeysWait("Hello world!", 30); cin.ignore(); return 0; } void SendKeysWait(char *text, int interval) { int ch; int ch2 …

Member Avatar for William Hemsworth
0
136
Member Avatar for tondeuse34

It looks to me like the code you wrote never releases the click. This is how you fully emulate a mouse click: [CODE] mouse_event(MOUSEEVENTF_LEFTDOWN | MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); // Left click mouse_event(MOUSEEVENTF_RIGHTDOWN | MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0); // Right click [/CODE]

Member Avatar for William Hemsworth
0
9K
Member Avatar for Jennifer84
Member Avatar for William Hemsworth
0
99
Member Avatar for wellibedamned

I happened to have already made quite a few functions to help do this. for example: [CODE] GetWord(char *text, char *gaps, int bzIndex /* 0 based index */); cout << GetWord( "#[]Hello_{World::" , "#[]_{:" , 0); // Returns "Hello" cout << GetWord( "#[]Hello_{World::" , "#[]_{:" , 1); // Returns "World" …

Member Avatar for wellibedamned
0
149
Member Avatar for blackhawk9876

If you are using MSVC you can just add: [CODE]#pragma once[/CODE] at the start of your code.

Member Avatar for William Hemsworth
0
181
Member Avatar for info04

I see nothing wrong with the function isUpperCase except from what mitrmkar sead, it would not work if you passed the function the characters 'A' or 'Z'.

Member Avatar for William Hemsworth
0
111
Member Avatar for dan_e6

This would have been very easy for you to test yourself, just made a quick test program: [CODE] int i = 5; cout << i++; // Still 5 [/CODE] [CODE] int i = 5; cout << ++i; // Now 6 [/CODE]

Member Avatar for William Hemsworth
0
14K
Member Avatar for Dannyo329

It is also possible to do graphics in a console window but I dont know if it what you are looking for. You could easily use BitBlt instead of just LineTo but here is an example: [CODE] #define _WIN32_WINNT 0x0500 #include<windows.h> #include<iostream> using namespace std; int main() { HWND console …

Member Avatar for Dannyo329
0
89
Member Avatar for Nemoticchigga
Member Avatar for vedmack

[QUOTE]Here's how to hide the console window[/QUOTE] You might have to add [CODE]#define _WIN32_WINNT 0x0500[/CODE] before you include the windows library to use the GetConsoleWindow() function.

Member Avatar for Ancient Dragon
0
113
Member Avatar for zidaneqrro

[QUOTE]You could also insert std::system("PAUSE"); between 18 and 19[/QUOTE] [url]http://www.gidnetwork.com/b-61.html[/url]

Member Avatar for William Hemsworth
0
142
Member Avatar for CodeBoy101

This function converts a string to lowercase usering OR [CODE] char *ToLowerCase(char *text) { char *str = new char[strlen(text)]; register int i; for (i=0;text[i];i++) str[i] = text[i] >= 'A' && text[i] <= 'Z' ? text[i] | 32 : text[i]; str[i] = '\0'; return str; } [/CODE]

Member Avatar for Radical Edward
0
112
Member Avatar for blah70

[QUOTE]I'm not here for people to be asking me why at the last minute.[/QUOTE] Perhaps we wouldent if you didn't leave it to the last minute... If you had started this earlier and realized that you need help mabey some of us would be more inclined to help you.

Member Avatar for ithelp
0
95
Member Avatar for dan_e6

Try this. [CODE] template<class type> inline bool IsPrime(type val) { if (val==2)return 1; else if (val == 1) return 0; else if (val%2==0) return 0; register bool prime = 1; for (register type i = 3; i < val/2;i+=2) { if (!(val%i)) { prime = 0; break; } } return …

Member Avatar for William Hemsworth
0
81
Member Avatar for Lotus_2011

btw, binary is spelt with 1 'n' :) heres my code: [CODE] #include<iostream> using namespace std; template<class t> inline char *toBase(t val, int base, char *values) { register char d = 1; t c; register bool _signed = val < 0; if(val >= 0) for (c = base; c <= …

Member Avatar for William Hemsworth
0
139
Member Avatar for n3XusSLO

I learned C++ off "C++ A Beginner's Guide", its a very good book and it is probably what your looking for. [url]http://www.amazon.co.uk/Beginners-Guide-Second-Guides-McGraw-Hill/dp/0072232153[/url]

Member Avatar for n3XusSLO
0
104
Member Avatar for Lotus_2011

Thats good if your just trying to print the values, but to actually convert between the different bases I think you have to make your own functions. I have already made them :) [CODE] #include<iostream> using namespace std; template<class t> inline char *toBase(t val, int base, char *values) { register …

Member Avatar for Lotus_2011
0
332
Member Avatar for The Dude

Ooooo, I made a game very similar to this in C++.. try it and see what score you can get. :)

Member Avatar for thunderstorm98
0
47
Member Avatar for Black Magic

'0100' is not a string. "0100" is. Only use ' ' for single chars, use "" for strings;

Member Avatar for Radical Edward
0
127
Member Avatar for Agni

Im quite anoyed I named myself Williamhemswort by accident.. its actually ment to be WilliamHemsworth =) I might change it some day...

Member Avatar for William Hemsworth
0
331

The End.