380 Posted Topics

Member Avatar for Labdabeta

I quickly threw together a drawing program in SDL and I am having a couple of issues with lag. The program lags really hard when the size is larger than about 700x700 pixels, and I cannot find anything other than a couple of SDL_BlitSurface calls to the 'image' surface in …

Member Avatar for Labdabeta
0
208
Member Avatar for mahesh113

When I ran your code I got the expected value of 30. As such I cannot explain why yours is outputting 35, but I can explain why fun had to return an integer reference instead of an integer. Basically when a function returns an int (a normal one) then it …

Member Avatar for Labdabeta
0
124
Member Avatar for Labdabeta

Hello. I am wondering how EOFs are indicated to either the cstdio functions or the fstream functions. Mainly I am wondering how it differentiates it from data. For example, if EOF is a 2-byte code wouldn't this break the system by inserting a 'false' eof flag: for (int i=0; i<256; …

Member Avatar for Labdabeta
0
182
Member Avatar for CPT

What you are asking about is called "type erasure" it is basically the combination of templating and inheriting. Unfortunately C++ does not support type erasure (as far as I know). As such you have to choose between templates and inheritance. Here is an example of each solution: Inheritance based: class …

Member Avatar for mike_2000_17
0
518
Member Avatar for Mak!zZz

Those links didn't work (at least not for me) please input them in a code block (just hit the "Code" button on the top of the editor). Also I have a feeling that your description of your problem will be insufficient. Try to clearly describe exactly what you are trying …

Member Avatar for Labdabeta
0
168
Member Avatar for Labdabeta

I notice that daniweb does not have a forum for logical circuitry :(. Does anybody know a good site that does? Is it possible for logical circuitry to be added to daniweb? I often like to design custom circuits from transistor or gate level and up, and I have never …

Member Avatar for Dani
0
218
Member Avatar for vishalonne

I think the easiest way to understand is to understand where Constructors and Destructors come from. Back in the days of C you did not have classes, only structs. As such you had to write a function that would create your struct (and usually return a pointer to it) as …

Member Avatar for David W
0
260
Member Avatar for Labdabeta

Hello, I am working on making myself a digital clock (as a fun little project) and I want to have two buttons, one to increase a value (like the hour) and one to decrease, mainly because I am tired of the clocks where you have to button mash the 'increase' …

0
151
Member Avatar for Labdabeta

Hello, I am very familiar with most of the sorting algorithms that are taught in first year university (as I just finished my first year in software engineering at the University of Waterloo). As such my current go-to sorting algorithms are insertion (on mostly pre-sorted data, or data where I …

0
222
Member Avatar for Azmah

I used learncpp.com, it is an excellent starting point. By the end of the tutorials you should know all of the advanced syntax of standard c++.

Member Avatar for Labdabeta
-1
473
Member Avatar for mat0pad

Im fairly certain that the language you are using is objective-c. You will most likely get more luck if you move this over to the objective-c section.

Member Avatar for Labdabeta
0
379
Member Avatar for maml

If you have so many return types, you may want to consider another option. Depending on your situation a class could be the exact solution you are looking for. For example if your function just does something to those variables it could very well be best to use a class. …

Member Avatar for annaharris
0
389
Member Avatar for mc3330418

Firstly, to clean up your code you should use a multidimensional array... I assume you know that arrays are basically a way to prevent you from doing this (at least statically allocated ones): int var1; int var2; int var3; Instead they allow you to cobine those variables into: int var[3]; …

Member Avatar for RonalBertogi
0
627
Member Avatar for Labdabeta

Hello. I read about the daniweb api competition thing and I have an idea of what I want to create. I have never done anything webby before (aside from using dreamweaver to make websites) and I think its about time that I did! I am hoping that it is possible …

Member Avatar for Ancient Dragon
0
1K
Member Avatar for Labdabeta

Hello, I only have a basic knowledge of ASM because every tutorial I have found (including Narue's) is based on using some kind of high level library or another. However when I look through disassemblies of pretty much any program I notice that all such library calls are gone. My …

Member Avatar for Labdabeta
0
559
Member Avatar for breezett93

Your issue is with integer conversion. Lets say, for example that you send the array that you showed, and say 4 for totals. At values[0][0] the result is 3 right? So you can pretend to swap in a 3 there... and swap in 4 for totals. What does 3/4 become …

Member Avatar for Labdabeta
0
3K
Member Avatar for rpcob

Okay, the issue is that `void f(int *a, int b)` is literally identical to `void f(int a[], int b)` from the compilers perspective, as such there is a conflict. This is because arrays are just stored as pointers. You can either remove the duplicate functions or rename them to fix …

Member Avatar for Captain119
0
4K
Member Avatar for mattster

Here is what I have to say. I used a mac all throughout my childhood, then got a windows computer for school and got used to it. Then when I got really into programming I put a linux partition on my laptop. So I have experience with most OSs and …

Member Avatar for Assembly Guy
0
857
Member Avatar for Labdabeta

Hello, I am making a number of libraries to help me with my projects and I am torn between two approaches. I will show you what each looks like. I have no idea which would be considered 'better' in general. Locals: #ifndef SOME_GUARD #define SOME_GUARD VERSION_NUMBER #ifdef __cplusplus extern "C" …

Member Avatar for mike_2000_17
0
227
Member Avatar for Xantipius

I was born Wednesday July 13th, 1994... it was Harrison Ford's 52nd birthday (if my math is correct).

Member Avatar for Xantipius
0
396
Member Avatar for gobiking

Your syntactical error is that max goes out of scope, but you have many more errors that are logical. For instance that for loop will run through and gather all the data into the array. Afterwards i will be 100... so you will only be using the very last thing …

Member Avatar for gobiking
0
3K
Member Avatar for robert.speciale

We need to know more... how does your find function work? what is an emp_data object? What is the problem with the code?

Member Avatar for robert.speciale
0
239
Member Avatar for <M/>

My friend made this one (a little quality lost in resize): ![ac497e49965c35613b39484c1701dc49](/attachments/large/3/ac497e49965c35613b39484c1701dc49.jpg "ac497e49965c35613b39484c1701dc49")

Member Avatar for <M/>
2
202
Member Avatar for gobiking

The issue is on line 26. You check if the sign isnt + OR isnt - OR isnt etc.. you want ANDs there. :)

Member Avatar for Labdabeta
0
296
Member Avatar for Musa_Jutt

Okay... first of all this forum really isn't for just giving away free code, so I doubt anybody will just give you the solution. Now, I assume you are familiar with c++, but judging by your question it is hard to tell. For instance, how are you storing your matrices? …

Member Avatar for DavidB
0
334
Member Avatar for Labdabeta

Hello. I have been looking long and hard for an image library that meets these criteria that I have for pretty much any library I will use (with some obvious exceptions): A) Cross-Platform (If at all possible) B) Weightless (or nearly weightless) C) Stand-alone (I hate having to include DLLs …

Member Avatar for Labdabeta
0
239
Member Avatar for Ecaz

I only recently learned to use GUIs but for the most part I think that it is a complomise. I use photoshop to create my images/textures then load them into my program. For 2d programs I usually draw out my view by hand to try to find out where to …

Member Avatar for Ecaz
0
405
Member Avatar for tensity

I think what Nathan Oliver was trying to say is that cin>>X; and getline(X,Y) do not mix very well. This is because of how those functions modify the internal pointer for cin. Putting cin.get() (without arguments) can sometimes rectify the problem by forcing cin to "catch up" to getline. Basically …

Member Avatar for tensity
0
255
Member Avatar for Kesarion

Based on how you are describing your problem I think you may be facing an irreducible problem. From what I understand from your post it seems that your problem can be boiled down to this: Find the subset of n objects from a given set with the highest value, given …

Member Avatar for Kesarion
0
265
Member Avatar for Labdabeta

Hello. As a Software Engineer I admit a slight lack of knowledge with hardware. I am usually quite good with any hardware that is contained within the case, my issues lie in networking. Usually I fix my own computer problems, but now I have a couple networking problems that I …

Member Avatar for Labdabeta
0
207
Member Avatar for beginner at c++

In general when faced with such problems you should try to do it yourself first. Typically grabbing pencil and paper is a good start. Write out a number in some base and try to convert it to some other base. First try a full example, then try to convert a …

Member Avatar for Labdabeta
0
269
Member Avatar for Labdabeta

Hello. I was reading http://xkcd.com/287/ while bored and thus decided to write a program that would solve such np complete problems. Here is what I got: #include <iostream> #include <vector> using namespace std; template <typename T> T NPMenuProblem(T desired, vector<T> options, vector<T> &ret) { vector<T> save=ret; T remainder; T min=desired; …

Member Avatar for Labdabeta
1
212
Member Avatar for Labdabeta

Hello, I am making a program that deals with bitmap files and I want to try to load bitmap data manually. The issue is that I cannot find a good resource for exactly what bitmap files can contain. [Wikipedia](http://en.wikipedia.org/wiki/BMP_file_format) has a decent article, but it is missing some important information. …

Member Avatar for Labdabeta
0
695
Member Avatar for AmrMohammed

I may be wrong, and I know I am not saying it all, but as I understand it the namespace in which cin/cout live (std::) is full of stuff... literally anything that is standard c++ should be in there (thats why they call it std, its short for standard, not …

Member Avatar for Tumlee
0
259
Member Avatar for azareth

I like my code compact, and consistent without too many files and well aligned code. I also gravitate to c-style code like this: MyGoodHeader.h: #ifndef MGH_H #define MGH_H ///@brief Puts the drawing cursor at a specific point in two dimensional space. /** This sets the raster position to the specified …

Member Avatar for <M/>
0
248
Member Avatar for victoria.lim.773124

It isn't skipping it... I'll explain: When you created searchId you defined it as returning void, and taking an integer array (id[]) and a reference to an integer (idNum). Then you told the compiler that right now the function does nothing (that ; actually kinda means {}... kinda). Anyways, normally …

Member Avatar for Labdabeta
0
687
Member Avatar for dustin.mcalister.58

Your code is incomplete. All you do is read 1 high and 1 low value, then output them... there is no code for anything more. To input more than one value you will need a loop of some sort, and to calculate the average you will need another. Your code …

Member Avatar for RvSon
0
202
Member Avatar for Labdabeta

Ok, so occassionally as I write my code, a non-printing character is insterted... according to code::blocks this character is actually two characters (\302 and \206). I have done much searching to solve the problem, but a solution has eluded me. I tried using the windows console type command on a …

Member Avatar for Labdabeta
0
828
Member Avatar for Zaina jee

Basically, a linked list for a stack will only have one link, pointing to the next element. As such your stack will look something like this: First->Second->Third->NULL (where -> indicates that the value has a pointer to the value to the right) In terms of the "standard" linked list struct: …

Member Avatar for Labdabeta
0
219
Member Avatar for munchlaxxx

I think this has to do with a disconnect between cin/cout token and line reads. As I understand it, when you cout<<"Text"; the console gets "Text" put into it and the cin read point goes to 5 (the position after "Text") but getline doesnt use this read point, so it …

Member Avatar for NathanOliver
0
113
Member Avatar for CHOCHOCHO

The issue is that reverselist as you wrote it expects a reference to a pointer of a nodetype, but you passed it num#.head_ptr which is of type pointer which will be converted to a const reference to a pointer of a nodetype (since num1,num2 are declared const in the function …

Member Avatar for Labdabeta
0
681
Member Avatar for Labdabeta

Hello, I am working on an arbitrary precision arithmetic library. I already created a version that just stored numbers as "before decimal point [unsigned array]" and "after decimal point [unsigned array]". The issue is that it is both inefficient and incomplete. I would like to incorporate complex numbers into the …

Member Avatar for deceptikon
0
236
Member Avatar for Labdabeta

Hello, I was partaking in the global game jam (where you have to try to make a game in 48 hours). I got my game pseudo-finished, but I cannot get it to render the scene properly. Here is the code related to the rendering: Code for opengl initialization: glClearColor(0.5f,0.5f,0.5f,1.0f); float …

Member Avatar for Ketsuekiame
0
270
Member Avatar for rikkie

Yeah, the problem is that ^ is not the exponent operator in c++. Rather a^b performs the bit xor operator on the two operands. As the bit xor operator requires two integer types to work (or even to make decent sense) it makes no sense to have it work on …

Member Avatar for phorce
0
2K
Member Avatar for qqaa007

(-1)^k = 1 if k is even, -1 if k is odd so: for (i=1; i<=N; i++) { if (i%2==0)//if it is even { sum+=1.0/(i+1);//since i is your k, you just divide by i+1 } else { sum-=1.0/(i+1); } } The rest is simply multiplying, then taking the square root.

Member Avatar for qqaa007
0
267
Member Avatar for xxwikkixx

rand() does not have the range necessary. It only generates a random number between 0 and RAND_MAX (just output that number to see the necessary range). As such you have three options: 1) Write your own pseudo random number generator (wikipedia has some good articlos on them) 2) Download a …

Member Avatar for vijayan121
0
198
Member Avatar for Labdabeta

Hello, I am using Code::Blocks, and recently any time I try to compile any program I get the errors "stray '\302' in program" and "stray '\206' in program" about every 20-30 lines. I know how to fix these (by deleting the non printing character(s) in the line in question) but …

Member Avatar for Labdabeta
0
295
Member Avatar for daniel.moore.5099940

Firstly, I notice a very obvious problem in your if-else-if statements in that you end with else Code Statement 1; Code Statement 2; Remembering that C++ doesn't care about whitespace you can rewrite that to be more clear on its function like this: else Code Statement 1; Code Statement 2; …

Member Avatar for Labdabeta
0
401
Member Avatar for Secone

Line 113 of your header file does not match its declaration. You have an extraneous array parameter.

Member Avatar for Secone
0
186
Member Avatar for Labdabeta

Hello, I was wondering how to make the windows explorer popups that many programs use. I want the one that browses files to either open or save a file rather than requiring the user to blindly type the filename.

Member Avatar for Ancient Dragon
0
257

The End.