921 Posted Topics
Re: Do one step at a time, and it's simple. >Create an application [CODE=CPLUSPLUS]#include <iostream> int main() { // Code here }[/CODE] >remember it is possible to make arrays of structs [CODE=CPLUSPLUS]#include <iostream> struct Student { std::string name; int id; int grade; }; int main() { // Create five students Student … | |
Re: You're kidding me? :icon_eek: [QUOTE]Your home planet is: Silbob Silbob is a square planet roughly 64 million light years away from Earth. It's covered in trees and smells strongly of cheese and tomato. The inhabitants of Silbob are all governed by "The Voice", which tells them what to do (but … | |
Re: Look up the [B]Sleep[/B] function to use as a delay for the message. To clear the screan, you can either use the [B]"system("cls")[/B], or better, do it manually:[CODE=CPLUSPLUS]void Clear() { DWORD n; DWORD size; COORD coord = {0}; CONSOLE_SCREEN_BUFFER_INFO csbi; HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE ); GetConsoleScreenBufferInfo ( h, … | |
Re: >but [B][COLOR="Red"]i[/COLOR][/B] have an assignment to give Hense the [B]I[/B]. You have to do it, not us. | |
Re: The structure of the program should look something like:[CODE=CPLUSPLUS]#include <iostream> #include <string> int main() { std::string escape = "x"; std::string choice; do { // Get input std::getline( std::cin, choice ); // Code here } while (choice != escape); }[/CODE]Also, part of your code is incorrect.[CODE=CPLUSPLUS]// Math Choice Variables int calcMinimum(); … | |
Re: I found this short one hilarious, not quite sure why :D. [URL="http://uk.youtube.com/watch?v=N4J73AnRE5A"]http://uk.youtube.com/watch?v=N4J73AnRE5A[/URL] | |
Re: Why dont you ask google that, and we will help with any specific problems you have. | |
Re: Hehe, pretty cool :icon_cheesygrin: I 95% of the time use google to check my spelling, as it's just plain awful. I found this one funny. [URL="http://graphjam.files.wordpress.com/2009/01/things-i-worry-about.gif"]http://graphjam.files.wordpress.com/2009/01/things-i-worry-about.gif[/URL] | |
Re: Use code tags, dont just colour in your code green. >[ICODE]int hoursworked[], payrate[];[/ICODE] What is this supposed to do? This does not make an array with an unlimited size if that's what you wanted. You need to replace those arrays with dynamic ones as you dont know what size they … | |
Re: A simple solution.[CODE=CPLUSPLUS]int balance; cout << "Balance : "; if (cin.peek() == '$') cin.ignore(); cin >> balance;[/CODE]Hope this helps :) | |
Re: The application begins at the [B]main[/B] function, so you can't assign a value to a variable outside of a function unless it's initialization. Here, you have two options.[CODE]#include <iostream> using namespace std; class desu { public: int lol; } s; int main() { [COLOR="Red"][B]s.lol = 5;[/B][/COLOR] cout << "Write some … | |
Re: For a windows solution, you could try this which will allow the user to press [B]any[/B] key to continue (not just enter):[CODE=CPLUSPLUS]void Pause(char *message = "Press any key to continue . . . ") { std::cout << message; HANDLE hStdin; DWORD cNumRead; INPUT_RECORD irInBuf[1]; if ( HANDLE(hStdin = GetStdHandle( STD_INPUT_HANDLE … | |
Re: I will be honest, I don't like it as much as the old one, though I'm pretty sure other people do :) I don't like having all the posts crammed on the left side of the page. Instead, I prefer to have them aligned in the centre like the old … | |
Re: How about the use of an [B]std::vector[/B], heres a small example.[CODE=CPLUSPLUS]#include <iostream> #include <vector> int main() { // Init vector std::vector<int> nums; // Add objects to vector nums.push_back( 5 ); nums.push_back( 6 ); nums.push_back( 7 ); // Add them all together int total = 0; for (size_t i = 0; … | |
Re: It's not exactly hard to memorize the code to make a window :P What's hard is being able to make the window do something interesting or useful. | |
Re: Create your own font, and you can change the font size yourself. Try changing your [B]MDIChildWndProc[/B]'s WM_CREATE message handler like this:[CODE]case WM_CREATE: { char szFileName[MAX_PATH]; HWND hEdit; hEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", "", WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_WANTRETURN, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, (HMENU)IDC_CHILD_EDIT, g_hInst, … | |
Re: Basically, inside the [B]limits.h[/B] file, there will be lots of [URL="http://msdn.microsoft.com/en-us/library/503x3e3s(VS.80).aspx"]macros[/URL] which define the maximum value for many different data types, It would look something like this.[CODE=CPLUSPLUS]#define MB_LEN_MAX 5 /* max. # bytes in multibyte char */ #define SHRT_MIN (-32768) /* minimum (signed) short value */ #define SHRT_MAX 32767 /* … | |
Re: What your trying to do with [B]trimleft[/B] will only work with a reference to a pointer which is pointing at an array of chars, like this:[CODE=CPLUSPLUS]void trimLeft(char *&a) { while (*a++ == ' '); a--; } int main() { char a[11] = " smith"; char *ptr = a; trimLeft(ptr); cout … | |
Re: You can't use a variable in a string like that, you have to manually add it to the string.[CODE=CPLUSPLUS]void title(const char *myTitle) // &mode? { std::string command = "title "; command += myTitle; system( command.c_str() ); }[/CODE]Also, what is the "[B]&mode[/B]" there for? | |
Re: Try using your head, or even a search engine. [URL="http://www.cplusplus.com/reference/clibrary/cstdio/fscanf.html"][B]Link[/B][/URL] | |
Re: Maybe return an index or value that will never be used, for example, if T = int, return (-1 for example), and then the caller can do a check to see if a value was found, if not, -1 is returned. | |
Re: I will be happy once I leave my highschool and go to college :icon_cheesygrin: Heh, but what really makes me happy is music, being with/talking to friends and going on holiday. | |
Re: I think what your looking for is a grid control, not a list box. They can be tricky to understand, but with the help of google, it shoulden't be too hard. [URL="http://www.codeproject.com/KB/miscctrl/gridctrl.aspx"][B]Here[/B][/URL] is a good example on how to make one. Hope this helps. | |
Re: >able to make pictures capable of animating If by that, you mean making an animated GIF image, you will have to download a library especially made for the GIF format. As for splitting up the image into 16 smaller ones, you can either use another bitmap library, or you can … | |
Re: [B]FindWindow[/B] will only return a handle to one window, to do this you will have to loop through all opened applications and hide them one at a time. Try looking up the [B]EnumWindows[/B] function, it may provide your solution. | |
Re: [CODE=CPLUSPLUS]unsigned long double result = 0.0; unsigned long double x = 1.0; unsigned long double y = 1.0; unsigned long double result2 = 0.0; [/CODE]There is no such thing as an unsigned double. As you only need to use integers, you should try using a 64-bit integer variable type instead … | |
Re: [CODE=C]void swapLines(int j, int k) { char *temp = malloc(sizeof(char) * 1000); temp = strings[j]; // What happened to the 1000 chars you just allocated? strings[j] = strings[k]; strings[k] = temp; } [/CODE][B][U]Memory leak![/U][/B] Remember to free any data you allocate using the [B]free[/B] function. | |
Re: Another way:[CODE=CPLUSPLUS]#include <iostream> template<typename t, size_t s> struct Array { t buffer[s]; operator t*() { return buffer; } }; Array<int, 5> getNums() { Array<int, 5> nums; nums[0] = 0; nums[1] = 1; nums[2] = 2; nums[3] = 3; nums[4] = 4; return nums; } int main() { Array<int, 5> nums … | |
Re: [URL="http://video.google.com/videoplay?docid=-6814048597272982882"]100 Reasons why Evolution is so stupid[/URL] Some good points are mentioned in this (rather long) video, but no where near enough to stop me believing in evolution :icon_cheesygrin: but personally, I dont think he knows what hes talking about 95% of the time :) | |
Re: I made the same program once, but much more complex. In the end I used a similar technique to what [B]Freaky_Chris[/B] mentioned, though I went the extra mile and added velocity & friction to make it look a little smoother. On top of that, it allowed the user the left … | |
Re: Try posting these in the [URL="http://www.daniweb.com/forums/thread83726.html"]Thoughts Of The Day[/URL] thread ;) Same applies for [URL="http://www.daniweb.com/forums/thread164912.html"]this[/URL] one. | |
Re: Next time, check the date that the thread was created before you post a couple hundred lines of badly formatted code which doesn't even work, especially without code-tags to somebody who probably had their problem solved a couple of years ago. Read [B][URL="http://www.daniweb.com/forums/thread78223.html"]this[/URL][/B]. | |
Re: >If you're desperate for small code, and you're in Windows there's MASM; but that's obviously a very different language from C++. And you can use an executable compressor like nPack, see the attachment. Just another option :icon_rolleyes:, but i've used it for compressing some programs/games before, and it works surprisingly … | |
Re: As far as I know, you have to put it before every function. I suppose you could save yourself a few keystrokes by doing this though.[CODE=CPLUSPLUS]#define DLLEXP __declspec( dllexport ) DLLEXP void someFunct() { // Code here }[/CODE] | |
Re: [CODE=CPLUSPLUS]// delete any previous data delete [] inStart; [/CODE]This is a very bad idea, and no data needs to be deleted, just overwrite it.[CODE=CPLUSPLUS]inLast = inStart = new inType[size]; // = new T[size]?[/CODE]Both [B]inLast[/B] and [B]inStart[/B] are not pointers and therefore you can not assign a pointer to them, they … | |
Re: [URL="http://www.daniweb.com/forums/thread24999.html"]http://www.daniweb.com/forums/thread24999.html[/URL] | |
![]() | Re: Well, theres a few ways you can do this, one method which I would probably use would be to read in the names, and manually remove all punctuation. To do that, you simply loop through each character, check if it is punctuation, if so, then erase it like this:[CODE=CPLUSPLUS]#include <iostream> … |
Re: Why people insist on using [ICODE]system("pause")[/ICODE] I just don't know, especially when you can just use [ICODE]cin.get()[/ICODE] or [ICODE]cin.ignore()[/ICODE] If you insist on having a function thats identical, here you go ;) :[CODE=CPLUSPLUS]#include <iostream> #include <windows.h> void Pause(char *message = "Press any key to continue . . . ") { … | |
Re: [URL="http://letmegooglethatforyou.com/?q=C%2B%2B+copy+file"]Link[/URL] | |
Re: Do you not know how a [URL="http://www.google.com"]search engine[/URL] works? Try typing in [B]"how to create file in c++"[/B] (your original question without the typo), and the first link has your answer. | |
Re: [ICODE]return strdup(temp);[/ICODE] Bad idea, you should never return a pointer to allocated dynamic memory, as you can quite easily forget to release that memory once you've done with it. The correct way to do this is to add a parameter containing a pointer to a buffer which you can write … | |
Re: A friend sent me this quite some time ago, I liked it :icon_cheesygrin: "Don't be reckless with other peoples heart's, and don't put up with people who are reckless with yours." Thats some good advice. | |
Re: Well, I found this amusing :] [URL="http://www.monproductions.com/blogs/wp-content/uploads/colonel/_nuts.jpg"]http://www.monproductions.com/blogs/wp-content/uploads/colonel/_nuts.jpg[/URL] | |
Re: [ICODE]#include <windows.h>[/ICODE] The start of a big fun windows application.. Woo!? ;) | |
Re: You can't do it the way your hoping to, but with some simple casting, it can be achived.[CODE=CPLUSPLUS]MyClass<char> mc1; MyClass<int> mc2; MyClass<float> mc3; void *arr[3]; arr[0] = reinterpret_cast<void*>( &mc1 ); arr[1] = reinterpret_cast<void*>( &mc2 ); arr[2] = reinterpret_cast<void*>( &mc3 );[/CODE]And, to then use an item from the array, you can … | |
Re: Learn to type, and read the rules. As you've given no information at all, the best I can do is assume [B][URL="http://www.winprog.org/tutorial/menus.html"]this[/URL][/B] is what you need. | |
Re: To add a new line, you have to rewrite the whole file. There is no way to insert data into the middle of a file. Ancient Dragon made a snippet which does something similar, but instead of adding a line, it deletes one. If you study the code, i'm sure … |
The End.