gusano79 247 Posting Shark

Is the file hosted behind an HTTP server? An HTTP HEAD request should result in a 404 if it's missing, but if it's there, it won't send the body (i.e., the file contents). cURL can do that.

gusano79 247 Posting Shark

Yes. If you look at the code, you'll see that a form is just another class that inherits from System.Windows.Forms.Form. It doesn't matter what kind of project it's in. As long as one of your projects is a Windows Forms project and it references the other one, you'll be able to use them both.

gusano79 247 Posting Shark

Are both projects set up as 'Windows Forms' projects? One of them should be a 'Class Library' project, probably form2.

gusano79 247 Posting Shark

^-- What Momerath said.

A message box would be a poor choice here as well. Why let someone select the menu item and then tell them "you can't do that," when you could simply disable it? As a general rule, I prefer to stop unavailable/disallowed actions as far upstream as I can--before they even happen, if possible.

Since I can't really add a little explanation to the menu item

Can't you? MenuItem has a ToolTip property.

gusano79 247 Posting Shark

How simple are you looking for? Also, have you tried to perform any of the conversions yourself yet?

gusano79 247 Posting Shark
gusano79 247 Posting Shark

Useful articles:

For an x86 machine:

Your mileage may vary on that last one; depends on the processor architecture.

gusano79 247 Posting Shark

could you please highlight those parts? i'm too tired to try to find them

Apart from mn.cpp, have a look at C::C() and D::D(); that's where you should be creating the new B and C, respectively.

gusano79 247 Posting Shark

Here's your problem:

int main(){
D* d;
d->add();

You've declared D* d, but you never assign it a value. It could be pointing anywhere. Then you go and try to use this uninitialized pointer. That is an excellent way to get a segfault.

I compiled this using GCC, and it said "warning: 'd' is used uninitialized in this function". Do you get a warning like this? If it does, you need to pay more attention to your compiler. If it doesn't, get a new compiler.

This is not the only place you're using uninitialized pointers; I count at least two more.

Bonus comment:

#include "A.h"
#include <vector>
#include <iostream>
using namespace std;
class A;
class B {

In B.h, when you include A.h, you're including the definition for the A class already. No need to declare class A; after that. Again, there are a few places you're doing this.

gusano79 247 Posting Shark

takes two int values A and B and returns a int values which suggets that this much number of bits are required to be changed to convert A to B.

Aha. Now we have a clearer problem statement.

The approach may be like that first we convert A and B to binary values

They're already binary values, no need to convert anything.

then we can take XOR of A and B cuz xor returns 1 for 0 1 or 1 0

Off to a reasonable start...

Further we should store the xor values in a array from where we can calculate the number of 1's .

...but I'm not sure why we think an array is necessary. The value of A ^ B is just another int.

And this value of number of 1's means that this much number of bits are required to be changed to convert A to B.

Correct.

Now you have an integer value whose bits are 1 where A and B differ--how would you count those bits?

gusano79 247 Posting Shark

ok here is my new code.This time if i key in -1234, i give me 4321..That Grest but how can i alo get the -(minus) to be behind....like 4321-....any ideas?

You could keep track of whether NUM_VALUE was negative to begin with and just output '-' at the end if it was.

Is it correct to but this so as to get a positive modulus?

Run it and see... what do you get?

By the way how can i make REVERSE AND NUM_VALUE constant.

The keyword is const.

gusano79 247 Posting Shark

Negative numbers are integers; it's not an error to divide by them. Here's a sample run of your original code (compiled with MinGW):

Enter any integer number
-1234
-4-3-2-1

Do you get something different?

gusano79 247 Posting Shark

Here convert A to B means that we are assiging value present in variable B to variable A. And they are of type int.

int BitSwapReqd(int A, int B) can only return one integer, and it's not going to be able to change the values of A and B because it's pass by value.

Do you have a more formal description of the problem? The task you posted isn't very clearly written.

gusano79 247 Posting Shark

I think it should boil down to number of differing bits in numbers and ther bitwise xor and and should be usefull.

Probably, but I'm interested in hearing what the OP thinks the task is.

gusano79 247 Posting Shark

Have you tried to write any code yet? If you have, please post it and we can pick up where you left off. If not, that's fine too--I'm just trying to find a helpful starting point.

Also, what's your major?

gusano79 247 Posting Shark

What does "convert A to B" mean? The function signature int BitSwapReqd(int A, int B) tells us A and B are both ints, so it's not clear what we're converting here. Do you have a more explicit definition of the problem?

gusano79 247 Posting Shark

For the math part, read about the shunting-yard algorithm.

gusano79 247 Posting Shark

Compare

cout << employeeName << setw(20) << employeeTitle << setw(19) << employeeAge << setw(21) << employeeSalary << endl;

and

cout << "Employee Name" << setw(20) << "Employee Title" << setw(18) << "Age" << setw(20) << "Salary" << endl;

I see two things to fix:

  1. You're not setting the same widths for the title row and the data rows.
  2. You're not setting a width for the employee name field.
gusano79 247 Posting Shark

Have you tried "\x1A"?

gusano79 247 Posting Shark

Try this: Instead of checking both the current node and the next node, just look at the current node. If the element you're considering is less than the current node, insert it before the current node. If it's greater or equal, move on to the next node. If you hit the end of the list without finding a place for it, just put it at the end.

Is it clear why that should work?

gusano79 247 Posting Shark

What's in renderScene?

gusano79 247 Posting Shark

Shouldn't this...

#define DLL_EXPORT __declspec(dllexport) __stdcall
#else
#define DLL_EXPORT __declspec(dllimport) __stdcall
#endif

...really be this...

#define DLL_EXPORT __declspec(dllexport) __stdcall
#else
#define DLL_IMPORT __declspec(dllimport) __stdcall
#endif

...?

gusano79 247 Posting Shark

Without code to look at, my best guess is that main.h doesn't have an include guard and is somehow getting included more than once.

gusano79 247 Posting Shark

You might get more help posting in a language-specific forum.

Regardless, ing doesn't mean anything in any C-derivative language I'm aware of.

gusano79 247 Posting Shark

What I'm doing/seeing:

  1. Hit the "Mark Forum Read" link--It says they're marked as read
  2. Refresh the page--everything shows up as having been read
  3. Close browser and go back to work/order a pizza/whatever
  4. Come back the next day, now some (seems like not all) threads in most of the forums show up as "new", even though there have been no further posts since I marked the forum as read

Possibly related: In the "Watched Articles" section, some threads are not being marked as new, even when there are new posts since I looked at them last.

gusano79 247 Posting Shark

What kind of controls do these boxes contain? For a Mastermind game, I'd guess they're probably radio buttons, but it's better to be sure.

gusano79 247 Posting Shark

Same thing has been happening to me in a variety of other forums too (everything I've visited in the Software Development area).

gusano79 247 Posting Shark

With finite storage, you can never detect all repeating decimals correctly. Say you completely fill up your fractional part array with the digits 1, 2, 0, 1, 2, 0, 1, 2, 0 (small array for example purposes). You might be tempted to say that it's 0.(120), but what if it's really 0.(1201201201), which is a completely different rational number?

Not much you can do about that. But here's a technique for converting decimal to binary that does the conversion and has some built-in detection for repeating representation. I don't know if this is anything like what you're already doing, but it looks like this could be easily adapted to whatever radix you want.

gusano79 247 Posting Shark

[stupid em dash, it showed up okay in the preview]

gusano79 247 Posting Shark

Framebuffer Object&mdash;I believe you can load your image into a texture, attach it to a framebuffer object, then use it as the 'read' FBO and the front or back buffer as the 'write' FBO. I haven't tried this myself; perhaps someone with direct experience can validate the idea.

gusano79 247 Posting Shark
unsigned djb_hash ( const void *key, int len )
{
  unsigned const char *p = key;
  unsigned h = 0;
  int i;
 
  for ( i = 0; i < len; i++ )
    h = 33 * h ^ p[i];
 
  return h;
}

Like i understand it multiplies it by 33 and raises h by the p

First things first: C doesn't have a "power" operator. '^' is exclusive OR.

gusano79 247 Posting Shark

Hi guys,

I'm trying to use the random number generator as part of the GSL library and it is working fine for a few hundred 'rounds' of my code (it is used quite a few times per round) but then i get an error message in the command window:

gsl: rng.c:46: ERROR: failed to allocate space for rng state
Default GSL error handler invoked.

Please post the part of your code that is actually generating the random numbers.

My guess is that you're creating a new generator every time you need a random number, and you're not destroying it after you're done. If that's the case, the allocator will happily reserve whatever amount of space it needs for each generator, and eventually you'll run out of memory.

gusano79 247 Posting Shark

Thank you very much... I am wondering what you mean by collision detection algorithm. I am using a ton of math for point-by-point collision detection (using triangle-ray collision algorithms) and very little math for bounding box collisions (obviously). I have no pruning implemented as I do not know of any pruning algorithms... does anybody have any suggestions on good algorithms to help speed up my collision detection?

I'm thinking of things like space partitioning, spatial indexing, sweep-and-prune algorithms--anything you can use to avoid actually comparing a pair of objects.

You might investigate some existing physics libraries (for example, ODE and Bullet) to see what kind of approach they take.

gusano79 247 Posting Shark

The thing is that that will add (c++ code, compiler dependant) 6*sizeof(float) bytes to each object. My question is, on average how many objects do most games have in them (an object consisting of a list of triangles in 3d space that are bound together), and how much RAM taken is too much? Basically should I add the six variables to increase speed but increase memory, or not?

A classic space-time tradeoff... really, it depends on the specific program and what you want out of it. If you require a high framerate, speed is probably more important. I'd say for a game-type situation, you'll probably want to take the memory hit.

For example (if I remember correctly), Chipmunk caches bounding boxes.

A useful approach if you're not sure which is better is to profile two versions of your code--one with the caching, and one without. Measure execution time and memory usage, and see what the difference really is for your hardware.

Some quick back-of-the-envelope calculations might prove educational as well. Let's be pessimistic and assume double-precision floats--that's 48 extra bytes per object, or one megabyte of extra storage for each 21,845 (and 1/3) objects.

I can't quote you statistics on how many objects a typical game might have, but remember: As the number of objects goes up, the number of relationships between them increases exponentially. For large numbers of objects, the dominating factor will be the choice of collision detection algorithm, not …

gusano79 247 Posting Shark

As I mentioned I have a machine that has 8 GB of memory.

I've re-read your original post a number of times, and I'm still not seeing where you said how much RAM you have.

but in this case I was testing my Development database and was loading 28 files one right after the other.

Are they all about the same size, ~500 MB? If so, there's your answer: ~1/2 GB * 28 = ~14 GB, so if the CLR isn't collecting garbage fast enough, it'll run out of memory quite easily.

Now my question is, since it is working ok now, is there a problem I still need to fix?

I would imagine so. One success does not necessarily mean the issue is fixed. It's possible that, while there still may be a problem, it only comes up under rare circumstances. That may be acceptable to you--if so, then make a note of it and move on.

If you're interested in understanding what's happening and why, please humor me and do your test with the performance monitor running.

gusano79 247 Posting Shark

So... how much RAM do you have in your system? I recommend you keep an eye on the Performance Monitor while your program is running. Watching the amount of free memory available might be very educational.

gusano79 247 Posting Shark

Read about Compiler Error CS0236. If str and con are both instance fields of a class, you can't use str to initialize con like that.

gusano79 247 Posting Shark

If you check my tags, I am using microsoft windows and windows API.

Even so, please take the five seconds to put it in the question as well. You'll get better answers faster.

EnumDisplaySettings can get you the current video mode or a list of available modes.

gusano79 247 Posting Shark

Hello,
I have been working with opengl and other graphics libraries and they all require the bits per pixel of the screen on initialization of a window. My question is, is there any way to get the system's preffered bits per pixel? or that of the monitor?

Depends on your OS. You can't use the OpenGL API until you have an OpenGL context, the creation of which is system-specific. Your operating system API should have some way to get both the current video mode and a list of all supported video modes.

gusano79 247 Posting Shark

Ya, I guess you got it right there, but will Java be enough for accessing it? Like, CAN I do it in Java? How I'll do it is a separate journey altogether :D but can I do it?

Maybe someone who knows for sure can chime in; I don't think Java supports promiscuous sockets. If that's true, you'd have to come up with a native library and a JNI wrapper if you still wanted to use Java to analyze the traffic. For example, jNetPcap.

gusano79 247 Posting Shark

A direction you might look in is your network card's scandalously-named promiscuous mode.

gusano79 247 Posting Shark

Never mind executing, this code doesn't even compile.

Pay attention to your compiler's output. Errors and warnings are there for a reason; they are usually trying to tell you something important. Please post them with your questions; this will help us help you.

Problem 1:

int main() {
    float Area;
    float r, h;
#define pi 3.41;

Don't put a semicolon at the end of the definition. It will be repeated every time you use it, which means that this line...

Area = (pi * r * r) + (pi * r * h);

...is preprocessed into...

Area = (3.41; * r * r) + (3.41; * r * h);

...which doesn't do you any good.

Also, the definition of pi should go outside of main() . It will work where it is, but having it at the top of the file by your includes makes everything easier to read and understand. Also consider capitalizing the whole thing (i.e., PI )--there's nothing wrong with lowercase letters, but it is a widespread convention to put C macro definitions in all caps, so that they may easily be identified as such.

Problem 2:

printf("THE AREA OF THE CILINDER IS:%f", &Area);

Don't pass addresses to printf unless you want to print the address. You want to just use Area here.

Problem 3:

return 0;
    getch();
}

That call to getch() will never happen. A return statement should always be the very last thing in …

gusano79 247 Posting Shark

Guys is it possible to get the details of an mp3 file like the Contributing Artist, Artist, Album, Year etc. and display it into a form?
I am using the IO namespace and I have almost tried all the methods and properties under my variable.

Does anyone know?

You won't be able to get this information using the standard I/O libraries. It's not part of the file system metadata; it's actually embedded in the file itself. See http://www.id3.org/ for technical details. As the Rev. says, there are libraries out there that take care of those details for you. If you don't use one of them, you'll have to open each file, locate the information, and read it in manually.

gusano79 247 Posting Shark

you should have two version one const and the other normal one.
For example;

int length()const ;
int length();

What does this get you that you don't already have with int length() const; ? The const lets you use length() when you have a const reference to an instance of your class, but it doesn't prevent anything when you don't. Or am I missing something?

gusano79 247 Posting Shark
gusano79 247 Posting Shark

What I need help with is getting the correct code for all of the neighbors that each cell has and also the code for each generation to correctly mutate.

All of those if statements are making my head spin. Are you familiar with the % operator?

gusano79 247 Posting Shark

May i distribute it? and how it works?

SQLite is public domain, so do what you want, including distribute it.

It's a C/C++ library, although you can find bindings to other languages if you look for them. There's a C-function API for managing the database files, and you write almost-standard SQL queries for data access.

gusano79 247 Posting Shark

i know what the unencrypted files look like but that doesnt help with the decrpytion surely?

If the file contains encrypted data only, then you're right. However, the program that saved the file may have included other information with the encrypted data for some reason. It's worth looking at.

gusano79 247 Posting Shark

Of course not. The idea that professional developers are always masters of the craft is a romanticized fantasy that hobbyists dream up. The reality is that only a small fraction of professional developers are more than average programmers.

Seconded; I've had to deal with some pretty awful code written by long-gone employees and contractors. I've also been surprised more than once by applicants with job experience who seemed to know what they were talking about until we got to some of the technical questions, where they were completely lost.

Most development positions I've seen do require experience in specific technologies, and your level of expertise will make a significant difference--the more skilled you are, the more it will show, but remember that perfection is not expected. Never stop learning new things--and there are always new things to learn.

Depending on your local economy and applicant pool, there may or may not be "junior" or "associate" level positions available as well. Such positions can often be frustrating, but they can be an excellent opportunity to demonstrate your skill and initiative. I don't see so many of those around my area, but your mileage may vary.

Finally: Practice, practice, and practice some more. Especially if you don't have any prior job experience, you can still talk intelligently about personal projects you've worked on in an interview.

gusano79 247 Posting Shark

If you prefer a database, but need an offline save file, and don't want to install a database server, you might look at SQLite.