gusano79 247 Posting Shark

hi there i am trying to build a linked list from read a file operation. this code only adds the first node to the list. the problem is i am facing with "error: request for member 'head' in something not a structure or union" error.

Which line is it complaining about?

I noticed this: new_stu->fn_next = (list)->head; is the only line where you don't dereference list --shouldn't it be new_stu->fn_next = *(list)->head; like all the others?

Also, your code seems to be a bit confused. If you're building a linked list with next fields in each structure, there's no need for LIST** list . All you should need is LIST* list ; the next field in each structure will point to the rest of the list.

gusano79 247 Posting Shark

So I've made some progress using the DLL file. I found that after adding the reference I could find the namespace included in the DLL file as well as one enum and two classes contained within the namespace.

So it looks like you have a .NET assembly; good.

Some functions can be found within the enum and classes that I know are meant to be used, but I've yet to figure it out.

Do you have any specific questions that we might be able to help with?

You might benefit from using something like .NET Reflector or ILSpy. Decompiling can give you an idea of what the classes and enums are for, if all you have is the assembly (i.e., no documentation, no debug symbols).

gusano79 247 Posting Shark

As a hint.

Instead of creating a new array for the Guid, I just did this:

Array.Copy(sockId.ToByteArray(), NewCommandData, sockId.ToByteArray().Length);
            Array.Copy(commandData, 4, NewCommandData, 16, commandData.Length - 4);

Ah, but now you're calling sockId.ToByteArray() twice again when it's not necessary. If you're going to reuse the result of a method and don't expect the returned value to change, it's better to squirrel the result away in a local variable. This makes the code clearer, and if it's something that's going to be repeated a lot, you'll see efficiency improve.

gusano79 247 Posting Shark

I've got a DLL file that has something like a database inside it

A question to get you started: Is this a native Windows DLL, a .NET assembly, or some other file that just happens to have the DLL extension? In other words, where did this DLL file come from?

gusano79 247 Posting Shark

is this valid? or is there a better (preferrably faster, more elegant) way of doing this?

Does it work the way you expect it to? That's the first test. =)

Here's a few things to improve:

1. The loop to add the GUID data shouldn't be inside the loop that adds the rest of the data. You'll end up with the GUID repeatedly copied into NewCommandData , which isn't what you want. It should be separate:

int TotalBytes = dataLength - 4 + 16;
int i = 0;

byte[] NewCommandData = new byte[TotalBytes];

//add the Guid byte array
while (i < 16)
{
    NewCommandData[i] = sockId.ToByteArray()[i];
    i++;
}
    
while (i <= TotalBytes)
{

    //add the commandData byte array
    NewCommandData[i] = commandData[i - 12];
    i++;
}

2. You're calling sockId.ToByteArray() multiple times inside a loop, but sockId doesn't ever change, so it's more efficient to do this conversion once, outside of the loop:

int TotalBytes = dataLength - 4 + 16;
int i = 0;

byte[] NewCommandData = new byte[TotalBytes];
byte[] sockIdBytes = sockId.ToByteArray();

//add the Guid byte array
while (i < 16)
{
    NewCommandData[i] = sockIdBytes[i];
    i++;
}
    
while (i <= TotalBytes)
{
    //add the commandData byte array
    NewCommandData[i] = commandData[i - 12];
    i++;
}

3. You don't need to copy each byte by hand; that's what Array.Copy is for:

int TotalBytes = dataLength - 4 + 16;

byte[] NewCommandData = new byte[TotalBytes];
byte[] sockIdBytes = sockId.ToByteArray();

//add the Guid byte array
Array.Copy(sockIdBytes, …
gusano79 247 Posting Shark

First, is there even a way to do it in c++? If i absolutely have to use an outside program/language then i will. And what are some examples of those programs/languages? (Id assume things like java aren't any of them)

It isn't about which language you use. There are methods for calculating the digits of pi that don't need arbitrary-precision arithmetic, for example, Simon Plouffe's method.

Start with the math--pick an algorithm, and that will tell you the kind of language features you need.

gusano79 247 Posting Shark

You could use the IndexOf and Substring methods to split it instead.

If you're feeling adventurous: .NET Framework Regular Expressions =)

gusano79 247 Posting Shark

I need to get the IP adress from a machine on the local network by knowing only it's name. Is there any way to do that?

Dns.GetHostAddresses

gusano79 247 Posting Shark
_ip.IPport = array[0];
_ip.Gate = array[1];

This looks backward; the port should come after the colon, not before.

internal class MyIP
{
    public string IPport { get; set; }
    public string Gate { get; set; }
}

Storing the endpoint information in strings is fine if all you want to do is display the values, but if you want to actually create a connection, you'll still have to create an IPEndPoint anyway. Also, there's no validation here, so something like "XXX#$%^&:snarkus" would get passed along as a valid IP address/port pair, which it isn't.

Picking at names... "IPport" can just be "Port" since you already have "IP" in the class name; no need to be redundant. "Gate" doesn't make any sense here, it should be "Address"; this is more or less universal terminology.

gusano79 247 Posting Shark

i see that the IP is stored in 'endpoints' does all the IP list is stored here is it stored 1 by 1 ..

If I understand you correctly, yes, every single IP endpoint in the file will be added to the list.

i need to load a new IP and port to vars on a button click,,
can you help me to make this a function and use it on a button or a instance to update the varable with latest ip and port ?

I'm not sure what exactly you want to do here... just take the last (latest?) line of the file and assign it somewhere? The last entry is in endpoints[endpoints.Length - 1] . As far as doing something from a button, if you make endpoints a member of the form, you can access it directly from the handler for your button's click event.

gusano79 247 Posting Shark

You can read a file with code that looks like this:

String infile1 = @"c:\ipAddresses.txt";
                StringBuilder currentWords = new StringBuilder();

                StreamReader sr = new StreamReader(infile1);

                try //read the file into lines of data
                {
                    do
                    {
                        currentWords.AppendLine(sr.ReadLine());
                    } while (sr.Peek() != -1);
                }
                catch
                {
                    MessageBox.Show("File [" + infile1 + "] is empty");
                }
                sr.Close(); //close the file
                String final = currentWords.ToString()

infile1 is the directory of your text file. StringBuilder is a special class designed for doing a lot of string concatenations. If you were to concatenate just a normal string many times, it would be very slow.
Once you have your final string, you can use the Split method to split the string into two strings around the colon.

I don't think StringBuilder is appropriate here, as we need to treat each line as a separate IP endpoint... all this does is cram the contents of the file into a string without separating them. A List<string> would be much more useful. But you're going to want to build IPEndpoints anyway, so why not convert inline? Also, StreamReader.ReadLine will actually tell you when the file's done; no need to peek.

Improved code:

List<IPEndPoint> endpoints = new List<IPEndPoint>();
StreamReader reader = new StreamReader("filename.txt");

string line;
while((line = reader.ReadLine()) != null)
{
    string[] parts = line.Split(':');
    
    if(parts.Length == 2)
    {
        // We have two parts, which are hopefully an IP
        // address and a port number. Let's see...
        
        IPAddress address;
        int …
gusano79 247 Posting Shark

what i want to do is to read a text file like this :

91.210.46.1:8080

and i want to separate the port and the IP ...
example :

IP IS : 91.210.46.1
PORT IS : 8080

i need to store the 2 values to variables when i call a function or something similar to it...

In general, you can do this kind of thing using regular expressions with grouping constructs.

This is a simple case, though, and you don't have to bust out a regex. Here's an example of how you might parse each line.

gusano79 247 Posting Shark

is the a simple point of a dll to move code out of that single exe (or is there another way to do that), so i would go and create a logger.dll, so that ill have a the exe file that uses the methods and functions from the logger.dll, instead of it being compiled into the exe

Short answer: Yes. The main benefit of separating your logger from an executable project is that you can now share the logger between many projects without having to recompile the logger every single time.

Longer answer: In .NET-land, both the exectuable and the DLL are called "assemblies"--here are some pages that explain in more detail.

gusano79 247 Posting Shark

True. I guess I was asking what the popular convention is?

There are a variety of conventions, none of which is overwhelmingly popular over all the others... since we're talking about C#, you could use Microsoft's official guidelines. Wikipedia has a more general discussion of various styles.

With respect to the inconsistency you mention, the Microsoft standard says:

The two abbreviations that can be used in identifiers are ID and OK. In Pascal-cased identifiers they should appear as Id, and Ok. If used as the first word in a camel-cased identifier, they should appear as id and ok, respectively.

By their own standard, PlatformID is incorrect, but I prefer it over PlatformId because the latter always reminds me of the id monster.

gusano79 247 Posting Shark

You're welcome, and good luck!

gusano79 247 Posting Shark

Keep in mind that the SqlConnection object won't close itself; you'll always have to close it manually. I recommend you always do it with a using block, for example:

using(SqlConnection connection = new SqlConnection(connectionString))
{
    connection.Open();
    // Do work here; connection closed on following line.
}

That, IMO, is the most readable and maintainable.

gusano79 247 Posting Shark

The only thing my project uses console for, is a convenient way for me to see the data its processing as it flows.

That should make it fairly simple to make the initial transition to forms, then.

All I would need a form for is a simple way for a user to input some variables, which at the moment are hardcoded, and in an xml file. And perhaps display some output on a label or somethig.

In that case, I recommend: Simple text boxes for the input, a button to start the processing, and a read-only multi-line text box for output. I prefer text boxes because they can grow scroll bars and you can select and copy from them--labels don't offer either.

Maybe I dont understand the differences between the types of projects, I thought the only difference was that one used the console window and the other used a windows GUI (I'm working with ms windows if that makes a difference).

This is true in the general sense that the code that does the work behind the scenes is the same in both cases, and the forms and console window are just ways of interacting with the user.

The difference is in how that interaction happens. A console application is typically rather linear, with one input and one output stream. A forms application is mainly event-driven, and has a different model for the user's "session" with your application. If you were starting from square one, you'd …

gusano79 247 Posting Shark

The issue is going to be moving from procedural code (the existing console app) to an event-driven model (the new forms app). How much of an issue this is depends on how well you've separated the core logic from the console stuff. You can't just "add forms" to the application--you will probably be able to reuse a fair amount of code, but I expect that you'll have to rewrite the entire structure around it, especially if your current experience is limited to console applications. ddanbe's "redesign" comment is appropriate; you'll need to think differently about how the forms application will work.

gusano79 247 Posting Shark

Please post the linker error. Better yet, the entire build output.

gusano79 247 Posting Shark

Ah, so the big_integer_t at the front is just defining what type the return value from the function is?

Exactly.

The last thing I'm hoping you can help with is the phrase "free them". We are told that the first function, big_integer_t bigIntFromString(const char *str); , contructs large integers from strings, and the second function, freeBigInt , frees the integers.

Does that mean anything to you?

Because it's a pointer, the "value" of a big_integer_t is only the address of a memory location. Creating a pointer variable reserves the storage needed to hold this address (normally 4 bytes on a 32-bit system), but it doesn't actually allocate any memory at that address. You still need to reserve enough free space for a BigInteger .

This is half of what bigIntFromString does--the other half being reading the string and deciding what number it represents. If you look at the definition of bigIntFromString , you'll probably see something like this:

big_integer_t b = malloc(sizeof(big_integer_t));

After that line, b is a pointer to somewhere in memory that is big enough to hold a BigInteger . freeBigInt does the opposite--it tells the system you're done with the chunk of memory you reserved by calling bigIntFromString , and it can now be used for other purposes. The most basic definition of freeBigInt will have just this one line:

free(b);

Once freed, the pointer still refers to the same location, but the system might use the memory there for other …

gusano79 247 Posting Shark

Does the line big_integer_t add(big_integer_t a, big_integer_t); create this add function inside the BigInteger struct?

No. You can't add functions to structures in C. You can in C++, but that's a different discussion.

Or is it creating its own instance of the BigInteger struct?

Also no. This is just a function declaration. All it does is say "Hey, somewhere in here there's code for a function called 'add' and here's some information about how you call it."

Remember that big_integer_t is really a just a pointer to a BigInteger . The function assumes you've already created a pair of BigInteger s to add, and that you're passing in pointers to them; and you have to assume that the return value also points to a BigInteger that's already been created--but there's no true guarantee that any of these pointers actually point to anything useful. You'd have to look at the code in the definition of add to verify that it's not returning garbage (it probably isn't).

Fun with pointers: It's possible that add is creating a brand-new BigInteger for its return value, but because you're passing it pointers, it could also, for example, just modify your a parameter and return the same pointer you passed in for a .

gusano79 247 Posting Shark

What is void * ?

It's the type of a void pointer; essentially, a pointer to somewhere in memory without an associated data type. I'm just using it to demonstrate the size of a pointer on your machine.

Am I right in saying that the first two lines were looking at the actual values stored (the short is 2 bytes, and so is the struct because all it contains is the short ), where as the last two were looking at pointers, and pointers are 4 bytes?

There are no actual values involved; I'm just printing out the number of bytes required to store values of each of those data types. You have the right idea, though--my fake BigInteger should normally be the same size as a short since that's all it contains. Same goes for the three pointer types. The idea there is to show that big_integer_t is clearly not the same thing as a BigInteger (because their sizes are different).

With the add and subtract lines:

big_integer_t add(big_integer_t a, big_integer_t); 
big_integer_t subtract(big_integer_t a, big_integer_t);

What is the second big_integer_t doing? The function is using a parameter called a of type big_integer_t , as well as just the type big_integer_t . I'm sorry, but I don't understand what this second parameter is for.

Those lines are declarations. Essentially they're saying that somewhere later in the code, there will be definitions for two functions, add and subtract , which both take two parameters …

gusano79 247 Posting Shark

(I did search for this, but didn't find exactly what I am looking for).

I am working on a function that will generate a sine wave at a given frequency AND sampling rate. Something that will "fill a 10k sample buffer with a 1 kHz wave at a 44.1 kHz sample rate".

My attempts so far are producing a "tone", but the tone changes in unexpected ways as I vary the inputs, and any reference along the lines of what I am trying to do might help.

I imagine that such a reference or a forum discussion might be "out there" somewhere. Appreciate any pointers....

I'm not aware of any simple reference for your specific question, but here's a quick line of thought for you:

  • A sample rate of 44.1 kHz is 44,100 samples/second
  • A 1 kHz wave is 1,000 cycles/second
  • The sine function has a cycle length of 2*pi

So. You need to scale your sine function such that 1,000 sine wave cycles would fit into 44,100 samples. Here's a rough look at how you'd derive code to fill the buffer:

for(i = 0; i < 10000; i++)
{
  // i is the sample index

  // Straight sine function means one cycle every 2*pi samples:
  // buffer[i] = sin(i); 

  // Multiply by 2*pi--now it's one cycle per sample:
  // buffer[i] = sin((2 * pi) * i); 

  // Multiply by 1,000 samples per second--now it's 1,000 cycles per second:
  // buffer[i] = sin(1000 * (2 * …
gusano79 247 Posting Shark
typedef struct BigInteger* big_integer_t; // so I know typedef allows you to assign different names to existing types, but this seems to be making a struct, but then has this pointer of type BigInteger after it, so is it making a struct of this type? What would that even do?

This line defines the type big_integer_t to be a pointer to a BigInteger . This is a handy shortcut--without it, you'd have to type struct BigInteger* everywhere you wanted a pointer to a BigInteger .

Here's a short program to run and ponder:

#include <stdio.h>

struct BigInteger
{
    short stuff;
};

typedef struct BigInteger* big_integer_t;

int main()
{
    printf("sizeof(short) is %d\n", sizeof(short));
    printf("sizeof(BigInteger) is %d\n", sizeof(struct BigInteger));
    printf("\n");
    printf("sizeof(void *) is %d\n", sizeof(void *));
    printf("sizeof(struct BigInteger*) is %d\n", sizeof(struct BigInteger*));
    printf("sizeof(big_integer_t) is %d\n", sizeof(big_integer_t));

    return 0;
}
void freeBigInt(big_integer_t a); // what does the 'a' mean? What sort of formatting is this? Thought you need a comma between variables.

freeBigInt is a function that takes a single parameter, a , which happens to be of type big_integer_t . Because of the typedef, this is essentially shorthand for void freeBigInt(struct BigInteger* a) .

There's no comma because there's only one parameter. Something with two parameters would look like this: void freeTwoBigInts(big_integer_t a, big_integer_t b)

big_integer_t add(big_integer_t a, big_integer_t); // From this line it seems that 'big_integer_t a' is a different variable, I didn't think you could have a space in a variable name.
gusano79 247 Posting Shark

if(textBox.Text != String.Empty)
{
//not empty (not null, even empty and null are not the same things)
}
else
{
//empty!

See also: String.IsNullOrEmpty or String.IsNullOrWhiteSpace; depending on what your needs are.

if(String.IsNullOrWhiteSpace(textBox1.Text))
{
    ...
}
gusano79 247 Posting Shark

There's no question in your post. What specifically are you having trouble with?

gusano79 247 Posting Shark

There are a couple of different ways to do what you're asking. Are you familiar with XPath?

gusano79 247 Posting Shark

Post code please? I think the file with your Main method would be the most useful.

gusano79 247 Posting Shark

Everytime i try to run it it screws up, it works but you can only do one move then you cant change direction any more. here is the code and I recommend that you try it first before replying

Compiles and runs okay, and I'm seeing what you're seeing. It looks like you're working your way toward a standard game loop. You've got a start inside the code for when the player hits 'd', but it kind of freaks out if you hit anything else after that.

Here's an outline of the kind of program structure I'm talking about:

void main()
{
    // Set up player position and direction.
    
    bool done = false;
    
    do
    {
        // Draw the board and player.
        
        // Get input:
        if(kbhit())
        {
            switch(getch())
            {
                case 'd':
                    // Set player direction to "right".
                    break;
                    
                case 'a':
                    // Set player direction to "left".
                    break;
                    
                case 'x':
                    // Set player direction to "down".
                    break;
                    
                case 'w':
                    // Set player direction to "up".
                    break;
            }
        }
        
        // Update player position based on player direction.
        
        // If player position is over something solid, set 'done' to true.
    }
    while(!done)
}

I'd start by organizing your code so it looks something like this example.

gusano79 247 Posting Shark

Can anyone tell me whats wrong with this code?
It throws this exception:
A call to PInvoke function 'Web!Web.SQLiteBase::sqlite3_open' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

[DllImport("sqlite3.dll", EntryPoint = "sqlite3_open")]
private static extern int sqlite3_open(string filename, out IntPtr db);

SQLite is a C library; it needs to use the cdecl calling convention, but the .NET framework uses stdcall by default. The following will probably work:

[DllImport("sqlite3.dll", CallingConvention = CallingConvention.Cdecl, EntryPoint = "sqlite3_open")]
private static extern int sqlite3_open(string filename, out IntPtr db);

Also, the EntryPoint parameter isn't strictly necessary because it's the same as the method name; if you want smaller (and IMO easier to read) code, you can leave it out:

[DllImport("sqlite3.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern int sqlite3_open(string filename, out IntPtr db);
gusano79 247 Posting Shark

The first step in solving that problem is to know what the problem is. I know of at least three different problems that mention a monkey and a banana.

No one knows the solution? I want detailed information about the complexity & heuristic function which we have to choose for the problem & not jokes!

You need to read people's responses more carefully.

Nobody knows the solution because you haven't expressed a clear problem. You ask "How to solve monkey and banana problem"--we're asking you to clearly define the problem first. If you can't do that, any answer we give you won't be very helpful.

gusano79 247 Posting Shark

Another useful method that only requires one line is Directory.GetFiles:

string[] matchingFiles = Directory.GetFiles("F:\\", "student_*.xml", SearchOption.AllDirectories);
var RootDir = new System.IO.DirectoryInfo("F:\\")

Just be aware that you need to specify a doube backslash in order to be interpreted a s a single one.

I recommend using @-style string literal for the search path in this case, as it results in code that in my opinion is a little clearer and easier to read:

string[] matchingFiles = Directory.GetFiles(@"F:\", "student_*.xml", SearchOption.AllDirectories);
ChrisHunter commented: Straight to the point and a great help +1
gusano79 247 Posting Shark

Hmm.

In my experience, the practical fact is that you don't really need much mathematical ability at all to understand programming. You can even become quite competent and (dare I say?) successful with no more math education than basic high school algebra.

That said, here's another practical fact: Any and all mathematics you learn can be used when you're programming, and the more you know, the better you're going to be at writing software. This is especially true of game programming. Half of the benefit is just knowing the subject matter. The other half is the type of problem-solving thought processes that more advanced math requires.

My advice: You don't need much math to be good at programming, but truly great software engineers are also math nerds. You can learn to be a math nerd--push yourself to take as many math courses as you can, but stop before you get burned out. Even if the material doesn't seem directly relevant, you'll be training your brain.

A short list of recommended courses/topics for any aspiring software engineer: Symbolic logic, discrete mathematics, linear algebra, probability and statistics, number theory, cryptography.

More advanced topics, if you're up for it: Multivariable calculus, differential equations, complex variables, optimization, abstract algebra, abstract geometry, game theory, stochastic modeling.

gusano79 247 Posting Shark

One of my clients has a software package that they use called Prelien2Lien, which has several thousand document templates. They'd like to be able to also use these templates outside of the software, but I haven't had any luck determining what file type they are. Ideally, I'd like to be able to convert it to DOC, PDF, ODT, or some other format that would be usable to us. Short of that, I'd like to be able to separate the text from the rest of the document (in an automated fashion, because there are hundreds of these templates) and reformat them.

...

I'm hoping that the format being used is somewhat standard and can be opened by other programs. Though I fully accept that the format may be proprietary and I'd be out of luck.

MS Word 2007 doesn't recognize it as a document template, and a quick Internet search wasn't very helpful either. My best guess is that this is a proprietary format and you're probably not going to have much luck trying to find anything out there that would convert it. I might be wrong, but I expect it would take a lot of digging to prove it.

If you want to try to extract the text, that shouldn't be too hard. I had a look with a hex editor, and the text blocks all seem to follow the same pattern.

Look for: 00 01 02 FF 00 00 00 00 00 00 00 00 (12 bytes)

gusano79 247 Posting Shark

Hey everyone, as the title suggests I'm trying to find a function or some code that'll execute a string of code in Lua. If anyone is familiar with Python, It would be the eval function. ex:

eval("y=1")
print(y)
>>> 1

Essentially, I'd like to do that same thing in Lua.

You're looking for luaL_dostring, in the auxiliary library. Should do exactly what you're looking for.

BTW sorry if I posted in the wrong area, Daniweb has no Lua forum and game development would be the closest area to it since it is used allot for scripting in game engines. Any help is appreciated, Thanks!

For future reference, Lua questions might fit better in the "Legacy and Other Languages" forum.

--smg

gusano79 247 Posting Shark

A quick comment on the 3 elements listed by chrjs: Do them in that order as much as possible. It's especially useful to make programming the last thing that actually happens, for a variety of reasons--notably that you'll be able to take advantage of newer technologies without having to rewrite older code.

gusano79 247 Posting Shark

I was trying to get at what you meant by your original question--is it just that you're trying to get a handle on polymorphism in general, or do you have some idea of what "multiple polymorphism" is supposed to mean, and you're looking for that feature in C#?

first i will tell what is polymorphism

there are two types of polymorphism:static and dynamic

static::which take place during compile time

dynamic::take place at run time,which is appreciated by virtual function

eg::float area(float a,float b)
{
return A*b;
}

function name is same where arguments only change A and b are arguments;

That's a poor explanation.

Exact meaning in simple word::one name having different forms or different behaviour of an instance depending upon the situations.

Getting there. How about:

"Polymorphism is a programming language feature that allows values of different data types to be handled using a uniform interface."

friend these are basics if u want more about polymorphism means i will provide you ok

...or you could take the extra five seconds and link something:

http://en.wikipedia.org/wiki/Type_polymorphism

http://en.wikipedia.org/wiki/Polymorphism_in_object-oriented_programming


You get polymorphism in C# with abstract classes, interfaces, and generic types. C# doesn't have multiple inheritance, but you can implement multiple interfaces if you want.

vedro-compota commented: ++++++ +1
kvprajapati commented: Correct! +11
gusano79 247 Posting Shark

I'd like to know what you think "multiple polymorphism" means, other than something that isn't multiple inheritance. Then we can talk about whether you can use it in C#.

gusano79 247 Posting Shark

What does "multiple polymorphism" mean to you?

gusano79 247 Posting Shark

When switching from 'wireframe' to 'solid', what would be a basic algorithm to render surfaces of an object? In a cube, for example, what surfaces are visible, and what surfaces are not?

You're talking about back-face culling. One way to do this: Don't draw surfaces that have a normal vector that points away from the camera position.

TotoTitus commented: He gave me a mathematically sound answer. +1
gusano79 247 Posting Shark

You also might look at String.Trim(char[])

gusano79 247 Posting Shark

What is Stroupstrup trying to get at with this exercise?

The point is that you have to be careful. If you keep allocating and never free anything, you will run out of memory.

What will happen if I run a program with an infinite loop? I am very reluctant to run such a program because I am fearful of doing something I can't undo.

That depends on the program. If you don't do anything in the loop, you won't run out of memory--it will just run forever. Normally you won't write infinite loops; there should always be something that will break out of the loop. The loop/allocate exercise is just a quick way to demonstrate what happens if you don't free memory you've allocated.

How does a programmer estimate the amount of memory that a program might need in order to avoid this situation? For example, the number of int variables times 4 bytes per int?

The exercise is looking specifically at dynamic memory allocation, probably using malloc . IMO, this is mostly taken care of by careful program design, because memory management in C++ is tricky.

gusano79 247 Posting Shark

I'm not sure exactly what you're asking, either, but here's a thought: Most developers I've met want to produce the highest quality software possible, but in practice, the level of software quality for a given project will depend on the risks involved and the cost of failure.

Consider the specific quality problem of an application that occasionally crashes for no immediately apparent reason. If this application is, for example, a simple image viewer, the worst thing that can happen is the user has to take a minute or two to restart the viewer. On the other hand, if the application is an embedded control system for a NASA space probe, a software crash could send it flying into the sun instead of into orbit around Mercury.

Of course, you'd want to fix the crashing problem in both cases. If the image viewer project was on a tight schedule, though, it is plausible that it could ship with the bug (Microsoft and Adobe products come to mind)--but you can bet your ass the space probe launch would be delayed until they fixed it.

gusano79 247 Posting Shark

Like this?
000
001
011
111
110
100

Exactly.

gusano79 247 Posting Shark

I was given a set of binary number to assemble it into gray code sequence: 111 000 110 011 001 100. Is their a specific way I have to do this? From What I read in the internet I think the following solution would be this:
Gray Code
000
001
011
110
111
100

Is this correct? would this be the final answer? Ive never done this before so Im not sure if this is correct.

The sequence you have there isn't correct--there should only be one bit of difference between each number and the one that follows.

That's basically all you need to know for this problem. Start with one of the numbers, then look through the rest for ones that only differ by one bit; those are the ones that could possibly come next. Repeat until either you've got a complete list (all six numbers), or you can't finish because you're stuck with numbers that all differ by more than one bit from the last one in your list. If you get stuck, then go back to some point where you had to choose between more than one number--this might be the first number--and choose a different one that fits.

gusano79 247 Posting Shark

Everything works fine on LAN. But when I run the server mode on a real server (RPS with public ip) there occurs a problem. Server receives a packet from my computer (non-public, local ip) and than tries to send a packet back. Unfortunately it never is received by my computer.

First thing to check is the client's address as it appears on datagrams sent to the server; see if it matches what you think its address should be. Your client machine may have a local IP address, but it also has to have a public IP address in order to send the datagram. If you're using a router, you may need to configure its firewall and port forwarding.

gusano79 247 Posting Shark

Maybe Nintendo DS homebrew? http://sourceforge.net/projects/devkitpro/

gusano79 247 Posting Shark

Can I get the control of an object just knowing its name?

If you're asking what I think you're asking, no.

Why: Setting the value of a.Name doesn't have anything to do with what type of control it is. a as ComboBox will always return null because here, a is only a Control .

If a is assigned a value that is acutally a ComboBox , then a as ComboBox will be able to get you the actual ComboBox object. Assuming you have a member of the form named comboBox1 , this might be what you want:

Control a;
a = comboBox1;
ComboBox combo = a as ComboBox;
combo.Items.Add("foo");

But in that case, it's easier just use comboBox1 directly.

gusano79 247 Posting Shark

The same idea works for UDP too. Every IP packet indicates the source IP address, so you still know where it came from. The client sends a datagram to the server, the server stores the client's IP address somewhere, and from then on the server can send whatever datagrams it wants to that client.

The main difference here is that with TCP, the sender's address is sort of hidden by the "connection" abstraction; with UDP, you have to keep track of who's been calling.

gusano79 247 Posting Shark

Need Help to fix this code because I can not find the errors so they can read successfully.

Can you be more specific? What isn't this code doing right? Does it compile, does it run, does is produce any useful output?

Also, please use CODE tags. It will prevent the smilies from happening... so "ASSUME CS:Codigo, DS: Datos, SS:Pila" will look right:

ASSUME CS:Codigo, DS: Datos, SS:Pila