129 Posted Topics
Re: Yeah they both seem fine ,.... however may i suggest that for trivial things like this try thinking up some simple test programs ,... I dont want to sound like a know it all but im starting to take the agile approach to coding in which you plan how to … | |
Re: Hi, Im no expert on SDL,... but just reading that line of code im fairly sure what the code is doing,... but not so sure as to what the result will be. [code] apply_surface( ( SCREEN_WIDTH - message->w ) / 2, ( SCREEN_HEIGHT - message->h ) / 2, message, screen … | |
Re: Hiya ,. I dont think polymorphism is neccessary here. I would simply convert the filter and data to classes. A class is the same as a struct in c++ (apart from different default permissions ie in a struct all members are public by default, where as in a class they … | |
Hi guys, I have been away from programming for a while and i started back today now that i have some time again. However i have run into a bit of a brick wall. im trying to impliment a queue with a simplified interface for holding messages. What I have … | |
Re: Do you mean that you want to choose which input stream you want at each usage as a function input or a saved member variable? if so then the cin/cout are of type istream, ostream respectively. An open file in read or write mode would also be of types istream, … | |
Re: Not sure if this is your issue but be aware that if you execute the following. [code] double cm = 0; double meters = 3.54; cm = modf(meters, &meters); [/code] The values of meters and cm will be 3 and 0.54 respectavely. I see you multiplying by 100 when you … | |
Re: I would say it isn't garbage but a wrap around of the variable, what you can do is to take the maximum integer your variable can hold. (should be in std::numeric limits) and divide the maximum integer number by your first int. this is basically saying how many times can … | |
Hi guys, Im working on a small console app to seek out all those pesky and disk consuming .ncb files and debug folders left from VS and destroy them so the space i need to backup the files is considerably reduced. I have got my recusrion algorithm to scan as … | |
Re: Hi i think its the cout call, I think that [icode]cout<<oss[/icode] would result in the first item from the oss being sent to cout. if you want the whole thing try using [icode] cout<<oss.str();[/icode] which prints the entire contents of the oss at once. | |
Re: Hiya, The issue as i have identified it was that you generated a new random number for each guess (thats a pretty hard game if u ask me) I have added a bool and an if around the generating number section of the code to prevent this. see my code … | |
Re: Not geting at what you want to do here, but generally visulisers are based on the audio waveform not the sound card buffer. I think what might be a better exercise would be to try to write a bit of code to flash the screen when you detect the bass … | |
Re: I would sugegst the use of stringstreams here. Make a function that accepts a string, build a stringstream from that then take all the words out one at a time say into a vector. then you can use the algorithm functions to search the vector. [code] vector<string> SplitString(const string& inputStr) … | |
Re: All it does is draw a teapot?! so whats the point here? | |
Re: Line 5: You give a forward refrence to the function taking only one long your actual function wants 4 and you pass 4 so change it to be [code] long binomal(long, long, long, long); //also change the actual function to include the names of the vars as i find it … | |
Re: To compare the numbers in each perosn with the winning numbers i would use 2 main steps. 1: Sort the numbers in ascending order. 2: Use a function. Use a function to compare one set to the other to see if they match [code] int checkLottoMatches(int* player, int* winning) { … | |
Re: On occasion it is. It depends on when DevC++ is first used if it is set to default as C++ or C (although to be honest i would stay away from devC++ all together) Its just one of those little things that bug people. So basically what were saying here … | |
Hi guys. Been coding away today decided that i would update an old program i did a while ago which was the base of an organisor application. So today i converted it to use STL instead of my hardcoded double linked class. I used list<> as my original implimentation was … | |
Re: I will assume here that the issue is that if cin>>intVar encounters an incorrect input it goes into a fail state. This will not correct itself. I suggest reading a character variable as this is what you want, then use the old c function isdigit() to check if the input … | |
Re: Well to my understanding ptr_a->a would be the first 4 bits (lower 4) so it should indeed be 0x0A as when we read hex remember we read right to left. so when you assign 4bits and 4bits your working right to left i think. Dont quote me on that but … | |
Hi everyone. Today i have been playing with templates and decided to make a generic question and answer function using templates to allow you to choose the return type for each call. Code below. [code] template< class T > T qAndA(const std::string Question,const T retType) { T retVar; std::cout<<Question<<std::endl; //ask … | |
Re: The result being 0 may be due to the fact that the function runs faster than one tick of the clock() function. Most pc's from roughly 5 years ago to today support high frequency clocks which if you are running windows you can use. (if someone knows that this is … | |
Re: Generally NULL which is integer 0 is used in many places to denote the lack of anything. Pointers when not valid or not yet assigned are also set to NULL to indicate this. Within strings NULL is used as you have seen to denote the end of string and is … | |
Re: I would use modulus and divide, this way is hard coded for a cretain max number size something to the effect of the following [code] int sumDigitsUntillUnder10(int number) { //check number islarger than 9 int temp = number; int result = 0; while(temp>9) { //need to do some work //add … | |
Re: Ok this application works but only just. If both buffers were of max size (128+128) the buffer would not be alrge enough to also hold the - and null characters at the end. However you want how it works so ill explian as best i can. concatString is a somewhat … | |
Re: I dont think the c++ standard sets a hard and fast way an implimentation must initilise built in types but i think compilers generally initilise to 0 to be kind to us. With things like vector and string they are always initilised as empty so i think they just decided … | |
Re: I would think its an issue with the arrays. Have you tried using the ';' as a file delimiter between each entry and a space between items that are part of the same field ie your array? file might have something like "a;b;1801640999;0;DDMMYYYY;DDMMYYYY;" for one record. With that the joy … | |
Re: I have a suggestion for you that should cause no errors and solve your problem. Input into a string, you can then check the input. following is a small code i have typed (not checked) just to give you an idea how i would do this (bear in mind a … | |
Re: Adding to narue's post the c++ alternative of malloc is using allocators which can be found in the <memory> header. Allocators allow you to get a chunk of memory without calling any constructors, Check this link: [URL="http://www.cplusplus.com/reference/std/memory/allocator/"]Allocators[/URL] You can then when you require it construct objects in this space, its … | |
Re: Hiya, i tried something similar (locking openGL app to 50fps ish) using performance counters. article:[URL="http://msdn.microsoft.com/en-us/library/ms644900%28v=VS.85%29.aspx"]MSDN performance timers[/URL] It gives a good explination of how to achieve what you want (geting time from one point in code to another) and the resolution can be extremely precise. Hope this helps | |
Re: Well i assume u want the basic layout. The Fact is a simple google search will show you that so easily why you would need a forum discussion is beyond me its just lazyness. But im a nice guy so here it is [code] class x { x(){;}//ctor ~x(){;}//dtor }[/code] | |
Re: You have various misisng braces indeed its true fixed your main [code] #include <iostream> #include <string> #include "USER.h" using namespace std; string Get_password(); string Get_username(); void Open_account_sucess(); void Error(); void Exit(); void Wrong_pass(); bool chk_input(User,User); int main() { bool is_exit = 0; string Password; string Username; User Fred(Preset_username,Preset_password,"FRED JOHNSON"); User … | |
Re: Hi i've solved the dynamic error problems by using the std::Vector container class. But i believe the memory allocation issue occours when your program loops back around at the end of the while loop and trys to dynamically allocate over the top of what you have there. Try cleaning up … | |
Re: Ok, You have encountered the cin fail that most of us encountered as we started. consider the following [code] int x; cin>>x; [/code] The "problem" with cin in this case is that cin is a stream(big buffer) so it accumulates everything. you asked for an int it gave you one, … | |
Re: You could do that if you were using a forms window or similar. On the console you could use the set position functions like so [URL="http://www.cplusplus.com/forum/beginner/1258/"]Set console window cursor position[/URL] These idea's may or may not be what your looking for but its all i can think of. Good luck … | |
Re: Hiya I agree what is posted above by david is correct but id like to point something out here for you [code] int incr10(int& num) // Function with reference argument { cout << endl << "Value received = " << num; num += 10; // Increment the caller argument return … | |
Hi all, Im wokring through NEHE's tutorials at the moment and building a cone approximation class to play with the code and learn from the examples but iv reached a snag. I cant get texturing the top curved part of the cone to work (i have called it a pyramid … | |
Re: Well if you keep a index to the array that says where the 1 is, you can easily just switch to change it or make a function or a class to encapsulate the lot. basically you are looking for something like the following from what i can see. [code] int … | |
Re: some thing like [code] char userIn; cin>>userIn; if(isspace(userIn)) { cout<<"whatever message"<<endl; } [/code] isspace() comes from cstdlib or ccctype to early in the morning for remembering just google it and it will confirm if you want it event driven then you will need something like a message loop in which … | |
Re: I think this is basically what magacin's code is doing, but you could if you HAVE to use a queue for whatever reason make a tempary queue with the same size the the one you need to read, save the poped values into it as you read then just loop … | |
Hi guys I had an idea for a fun project i would like to try, but i really have no idea where to start reading about the api's data formats and the likes. [U]What i want to do[/U] I would like to make an application as the start of an … | |
Hi guys, Basically in my system i use 2 drives one soley for dev work and applications the other for storing media .exe's etc etc. I put my "my documents" folder on my storage drive (preaptly named s:) But since i reformatted c:/ when i try to acces my documents … | |
![]() | Re: Hi i have a few VS installs here and some other sdk's so im not sure which is right but i find allot of them at "C:\Program Files\Microsoft SDKs\Windows\v7.0\Lib" if this is wrong for you change the version number from v7.0, i also have a V5.0, v6.0A and v7.0A. gdi32.lib … ![]() |
Hi, I think im trying to break c++ again in making it do something it does not want to do. Basically i have a logging class im making which simply takes a string stream and pumps it into a file. But i want 2 different versions one that trys to … | |
Re: Um i dont know if this really helps but this peaked my curiosity so i made a program to test all these suggested methods. I have attached the results(.txt file) in a zip file with the source codes i used which i explain here. basically what it does is defines … | |
Re: No offense, but anyone who knows anything about c or c++ will know all those answers. this isn't a do my homeowrk forum this is a place for discussing problems in what you are doing and geting some advice. I refer you now to the teachings of tundra010 [quote] Here … | |
Re: If you want and are ok with low level things then i think openGL might be what you are looking for for basic 2d. but it can do some pretty intense things when you get there. I think it is better than directX for 2d apps but thats my opinion … | |
Re: Hi im not to sure as that code is kind of beyond me but upon study i get a feeling maybe it is this. Your complicated map has a List of strings. in the template function you have a temp which is simply a string. Such as you add to … | |
Re: Just a thought, if you divide the cost per hour into a cost per minute you can make all your code integer multiplication and addition with a few subtractions. I dont know if you want to do that kind of simplification but as i said was just a thought. You … | |
Re: Indeed he is correct, openGL prefers floats over doubles for higher performance on the GPU, also from what i understand of SIMD SSE2 unless it has been expanded in later editions those instructions were optimal for floats also. If this has been changed (since 03 when the book i read … | |
Re: Quite simply you are reading into an int variable. Therefore once text is read the stream goes into a fail state, which isnt as catastrophic as it seems. All this tells you is that the input encountered something it could not put into an int. A string. To resolve this … |
The End.