624 Posted Topics
For an assignment I must implement an operator -= to remove points from a canvas (that have been plotted broken line graph style). Here's the part where the problem is occuring. It certainly removes points, just not the right ones seemingly and not all of them. It doesn't make much … | |
Re: I would use structs to represent the cards, rather than just arbitrary arrays. Here's a blackjack game I wrote a few years ago for school that might give you the right idea. [code=cplusplus] /************************************************************************* Project: Lab 4 Files: main.cpp Date: March. 24, 2008 Author: Kyle Wesley Class: 2D Instructor: Cindy … | |
Re: You forgot to include the string header: #include <string> without this, the compiler doesn't know how to handle string datatypes. | |
| |
![]() | Re: I don't really see the point in initializing this variable in the switch. Could it not be initialized at the start? It's generally considered bad practice to do things like this. |
Re: If you really want to keep it all on one line like that, something like this is generally a sure fire way to make this sorta thing work: [code=cplusplus] cout << article[(static_cast<int>(seed_val) % MAX_ARTICLES)]; [/code] | |
Re: I'm no linux guru, but i think you could redirect the output of ls to a file within a system() call. I forget how to do this in *nix but in windows it would be something like: dir > file.txt Then this file can be opened for input and parsed. … | |
Re: Most generaly, link errors are caused by a mismatch in a function/method declaration and the actual implementation. Hence being unable to link the two (and possibly more in the case of overloading). For example, this would result in a link error: [code=cplusplus] void Foo(int, int); int main() { Foo(10, 10); … | |
Re: In this forum you need to show effort for people to help you. Take a stab at it and post what you're having troubles with. | |
Re: Hmmm it's not very clear what the problem actually is...but I think the reason why its looping that text is because you forgot to clear the cin stream. Use this line: [code=cplusplus] cin.clear(); cin.ignore(cin.rdbuf()->in_avail()); [/code] Put that before every 'cin' line you use to clear excess characters from being reaad … | |
Re: [QUOTE=blackryu21;712450]I have to match up airlines for flights in c++, but for certain matchups, the value would be equal to x. I need help to do it. Here's the code I have so far: [code] #include <iostream> using namespace std; int main() { int nROWS = 4; int nCOLUMNS = … | |
Re: Hmmm i think your first (nested) delete loop should not have the [] operator after the delete line. The way I understand it, there at [i][j] the thing being deleted is no longer an array. So: delete _3DarrayOfSet[i][j]; should suffice. If I'm wrong, and _3DarraOfSet[i][j] is in fact a pointer … | |
I've recently bought a linksys wireless n router, then it failed completely (i assumed a power outage fried its eeprom?) so I bought another (same one). This one works fine, except it randomly drops my wireless connection about once per day for about 15 minutes. What would cause this?! I … | |
Re: Hmmm. I don't think that the ^ operator works in c++. I could be wrong =\ , but I think you must use the POW func in the cmath header. I think that ^ is some sort of bitwise XOR or XNOR or something of the sort. | |
Re: Check out[URL="http://www.daniweb.com/forums/thread150836.html"] this related thread[/URL] | |
Re: Go [URL="http://www.glprogramming.com/red/"]here[/URL]. | |
Re: A struct is a simple user-defined data type that can contain other (user defined or standard) datatypes. For example, if you wanted to create a struct of golfer names and scores: [code=cplusplus] struct SGolfer { //struct members go here char * _szName; int _iScore; }; [/code] This can now be … | |
Re: You're misusing while loops, use a for loop instead. And use strlen(szString) to calculate the length of a null terminated c style string. ie: [code=cplusplus] char const * kavi("my shiny sword"); cout<<kavi<<endl; cout<<"now reversing the word"<<endl; cout<<"Length is "<<strlen(kavi) <<endl; for(int j=strlen(kavi); j>=0;j--) cout<<kavi[j]; [/code] Strlen will return an int … | |
Re: Hah. There's whole courses on stuff like this. I'd sugguest you take one if you really plan on writing this. Or pull your hair out! | |
Re: I think you need to isolate your issue a little better, and post as little code as possible. That's too much code! Step through/into the code (F10 and F11 in VS05) and keep an eye on the values of your locals to find where it actually fails. | |
Re: Generally a link error occurs when the linker cannot resolve a function to its declaration. The solution to this was already posted. | |
Re: Make a function like this (with iostream included and the std namespace): [code=cplusplus] ostream & Flush (ostream & myStream) { myStream.clear(); myStream.ignore(myStream.rdbuf()->in_avail()); return myStream; } [/code] Then call it for whatever stream you want to clear, and it supports chaining. ie Flush(cin) >> iInput; | |
Re: My price is $250.00, which is much cheaper than any software companies would charge, even though that program would take about 2 minutes to write. | |
Re: What do you need help with? Are you expecting someone to write this code for you? | |
Re: I would sugguest you use linked lists for this sort of thing (or a binary tree). But if that's outside your knowledge, you could use a horribly inefficient check loop: [code=cplusplus] int const MAX = 10; int main() { int iNum[MAX], iRand(0); bool bFlag(false); for (int i(0); i < MAX; … | |
Re: Well remotely i'm not sure if that will work...but if you know the process name or the PID, you can do a system call from c++ or just run a batch containing: taskkill /f /PID [PID] or taskkill /f /IM [process name] I'm not sure of how to obtain the … | |
Re: use this snippet in your code: [code=cplusplus] #include <crtdbg.h> int main() { _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); return 0; } [/code] This won't actually detect where the leak is occuring, but can give you a good idea. For example, if you are allocating 20 bytes of memory for a certain array, and … | |
Re: I hate it when people offer me money for my homework. If it doesn't make sense to you, perhaps you've chosen the wrong field? I mean, how are you going to explain to your boss that you have no idea what he's talking about your first day of work? Maybe … | |
Re: Is that how the binomials are saved to the file? If so, then you will need load it into a string, then parse the string. If you aren't looking for robustness and user usability, you could just say the 4th and 9th letter in the string are to be used … | |
Hi, I'm not sure I understand my teacher properly, but he wants me to use the CCTOR of class CPt in the CCTOR of class CCanvas to fill a dynamically allocated array. I'm at a loss of how to call it...maybe a little code will help this make more sense: … | |
I'm not too sure why I'm getting memory leaks...hopefully someone here is wiser than me, and can help me find it :P . [code=cplusplus] #include "Canvas.h" CDrawer CCanvas::gCanvas(RGB(0,0,0), 1); int const GREEN(20000),BLUE(50), RED(200), THICK(3); CCanvas::CCanvas(void): _iSize(0), _cptPoints(0) { } CCanvas::CCanvas(CCanvas const & tmpCanvas): _iSize(tmpCanvas._iSize) { if (_iSize > 0) { … | |
Re: I don't think a class is neccessary here. It's alot of overhead for doing something very simple. Instead, just use an array representing the right values, and a single buffer for value entry and comparison. To check times, use this: [code=cplusplus] #include <ctime> #include <iostream> int main() { int iVal(0); … | |
Re: There's a few solutions to that 'problem'. I usually try and keep the clutter out of main by putting all the meat and bones of main() into functions and only using main to call them, and potentially have a loop (which would return you to the first menu for example). … | |
Re: I'd send you the drawer lib my teacher wrote for us, but I'll have to check with him first to make sure it's alright. | |
Re: Hmmmm, I'm not to sure if your teacher is forcing a particular method, but mod is useful for this kind of thing: [code=cplusplus] int iNum(7); bool bPrime(false); //since even primes have a factor of 1 //and themself, start at 2 and stop 1 less than the number for (int i … | |
Re: There is no way to do that without the use of arrays, or some array based library algorithm. What form of string are you using? Because I think in the string.h library there is some commands for doing this kind of thing - although I'm sure you haven't learned about … | |
Re: Unfortunately, C++ won't be able to write an operating system for you. You'll need to dig deeper into the dreaded Assembly language, and then even deeper than that into the god awful machine code. If you really want to experiment with operating systems/memory/registers etc... I would sugguest you build an … | |
Re: if your using the iostream library, strlen(szString) + 1 //+1 for the null terminator will work just dandy. | |
Re: I think you are trying to create an html file, which does support colored text. To do this, you will need a very basic knowledge of both the fstream library and html coding. If you do not have this knowledge then it will be very difficult to help you. | |
Re: If you have the actual sound data in some sort of array/list and the frequency, then just create a for loop to iterate each element - and draw pixel by pixel the data to the screen (with some sort of drawer lib). This will take a bit of math (to … | |
Re: [QUOTE=kux;696646]Compile this code with MSVC2005 [CODE] unsigned short x = 20; unsigned short y = 20; for ( unsigned long i = 0; i < x * y ; i++ ) { cout<<i<<endl; } [/CODE] and u get warning C4018: '<' : signed/unsigned mismatch why? i mean, it all runs … | |
Re: [code]for(case=1; case < 9999; case++;) { t1 = Input_Time(Time&, int) t2 = Input_Time() totalSeconds = Time_To_Seconds(Time t1, Time t2);[/code] these lines should be replaced with: [code] for(int i=1; i < 9999; i++) { Input_Time(t1) t2 = Input_Time() totalSeconds = Time_To_Seconds(t1, t2); [/code] this line (18): [code] void Input_Time(Time&, int, int, … | |
Re: Well I don't have time to go through all that code, but assertion errors are usually caused by attempting to delete a value that doesn't exist. It doesn't seem like your code uses any DMA though, so it could be internal (included libraries). Try stepping through/into your program (f10/f11) to … | |
Re: I would not recommend using the microsoft website for any sort of help. It's pretty bad in general. This is one of the reasons why; they seem to have alot of strange and/or outdate (C language) snippets posted. | |
Re: Are you asking the forum to do your homework for you? | |
As a part of an assignment I am to construct a copy constructor for a bitmap loader/manipulator class. 2 of the things that must be copied are struct headers (containing a bunch of useless bitmap information, with a tiny bit of useful stuff). Image Headerfile: [CODE=cplusplus]#pragma once #include "Drawer.h" #include … | |
Ok, so I'm trying to prove to my teacher that Div and Mod isn't always the best way to solve things. So i created this tiny program, held entirely in main.cpp : [CODE=cplusplus] //Project: Mod_Efficiency //Author : Kyle Wesley //Descrip: This was made to prove that mod/div operations are often … | |
I don't know what's going on here...but I always seem to get 2 leaks of 40bytes each consisting of FF FF FF FF.... Even with all the code commented out, I still seem to get these leaks. I'm running Visual Studio on Vista SP1, so perhaps a combatibility issue? Or … | |
I recently bought a new wireless router (a Linksys 802.11n). The power failed and my brother had unplugged it from the surge protector and into the wall >.< . Well a day later it was acting haywire, it was very difficult to connect to wirelessly and would disconnect after about … | |
Re: Should work. If loading the XP cd on boot doesn't work, then format (after a backup of course) the drive and try again. |
The End.