129 Posted Topics

Member Avatar for BigDeveloper

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 …

Member Avatar for BigDeveloper
0
118
Member Avatar for Shofahi

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 …

Member Avatar for Kanoisa
0
68
Member Avatar for goldmn480

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 …

Member Avatar for Kanoisa
0
123
Member Avatar for Kanoisa

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 …

Member Avatar for Kanoisa
0
167
Member Avatar for ganesh_IT

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, …

Member Avatar for sowmyadantuluri
0
162
Member Avatar for jmcorpse

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 …

Member Avatar for Kanoisa
0
120
Member Avatar for frogboy77

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 …

Member Avatar for frogboy77
0
119
Member Avatar for Kanoisa

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 …

Member Avatar for Kanoisa
0
2K
Member Avatar for Peter_morley

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.

Member Avatar for Peter_morley
0
238
Member Avatar for vijaybrar

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 …

Member Avatar for Fbody
0
160
Member Avatar for Sismetic

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 …

Member Avatar for Kanoisa
0
237
Member Avatar for unsureandunclea

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) …

Member Avatar for Kanoisa
0
124
Member Avatar for koolman123
Member Avatar for daviddoria
0
124
Member Avatar for SkonTeam

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 …

Member Avatar for SkonTeam
0
163
Member Avatar for JSpudMonkey

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) { …

Member Avatar for JSpudMonkey
0
127
Member Avatar for techie1991

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 …

Member Avatar for Kanoisa
0
573
Member Avatar for Kanoisa

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 …

Member Avatar for Kanoisa
0
326
Member Avatar for newbie_to_cpp

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 …

Member Avatar for ceriamultimedia
0
102
Member Avatar for pdk123

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 …

Member Avatar for pdk123
0
142
Member Avatar for Kanoisa

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 …

Member Avatar for mike_2000_17
0
145
Member Avatar for raghamayee

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 …

Member Avatar for mike_2000_17
0
144
Member Avatar for techie1991

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 …

Member Avatar for Ancient Dragon
0
163
Member Avatar for darkroad

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 …

Member Avatar for ananda2007
0
168
Member Avatar for EdAtTheAirport

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 …

Member Avatar for arkoenig
0
202
Member Avatar for yapkm01

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 …

Member Avatar for arkoenig
0
1K
Member Avatar for laughnan

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 …

Member Avatar for Kanoisa
0
4K
Member Avatar for blaisemcrowly

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 …

Member Avatar for MooGeek
0
2K
Member Avatar for timb89

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 …

Member Avatar for Kanoisa
0
100
Member Avatar for carbonfinger

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

Member Avatar for Kanoisa
0
137
Member Avatar for mavs123

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]

Member Avatar for daviddoria
-1
111
Member Avatar for rom87

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 …

Member Avatar for Kanoisa
0
90
Member Avatar for spankboy11

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 …

Member Avatar for Kanoisa
0
247
Member Avatar for fire_

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, …

Member Avatar for Kanoisa
0
167
Member Avatar for ^Y^ nobody ^Y^

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 …

Member Avatar for Kanoisa
0
164
Member Avatar for furtaker

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 …

Member Avatar for furtaker
0
458
Member Avatar for Kanoisa

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 …

Member Avatar for mike_2000_17
0
487
Member Avatar for dadam88

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 …

Member Avatar for Kanoisa
0
108
Member Avatar for helpingdeed

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 …

Member Avatar for Duoas
0
116
Member Avatar for drjay1627

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 …

Member Avatar for vijayan121
0
129
Member Avatar for Kanoisa

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 …

0
59
Member Avatar for Kanoisa

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 …

Member Avatar for Kanoisa
0
123
Member Avatar for yoni0505

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 …

Member Avatar for yoni0505
0
960
Member Avatar for Kanoisa

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 …

Member Avatar for Kanoisa
0
194
Member Avatar for onako

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 …

Member Avatar for mike_2000_17
0
4K
Member Avatar for dla0581

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 …

Member Avatar for Kanoisa
-2
99
Member Avatar for rootchord

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 …

Member Avatar for aslamnandyal
0
188
Member Avatar for old_jefrey

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 …

Member Avatar for mrnutty
0
106
Member Avatar for thedoodler

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 …

Member Avatar for Kanoisa
0
1K
Member Avatar for 2008macedonkon3

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 …

Member Avatar for Kanoisa
1
2K
Member Avatar for Anyzen

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 …

Member Avatar for Kanoisa
0
149

The End.