Are you able to run your program successfully on your computer?
gusano79 247 Posting Shark
Are you able to run your program successfully on your computer?
When I need to serialize things to a byte array I usually write the array to a MemoryStream first then use the binary formatter to serialize it to whatever (file, another byte array whatever).
The question I had was, can I just serialize a byte array instead of converting it to a memory stream and then back again?
The binary formatter says it needs a "stream" to serialize...is there another method?
BinaryFormatter.Serialize writes to a stream, so if you want to serialize an object to a byte array, using a MemoryStream is the simplest way to go.
I'm not sure what "write the array to a MemoryStream first" is intended to accomplish; you can create an expandable MemoryStream without creating a byte array first.
Do you always get the same error in the same place, or does it change?
Is there a specific reason you need to use the clipboard? It might be part of the problem.
Hello,
I am working with genetic programming for classification techniques in data mining.I am not very much clear about how to perform genetic programming in C.
Can i please get some sample code of genetic programming... An example program for any application would be fine. I just need some reference and it is nowhere available.
Awaiting some help...
Is the problem that you're not clear on what genetic programming is, or that you don't know how you'd implement a genetic algorithm in C?
If it's the former, start reading about GP.
If it's the latter, do you have any specific questions?
this code is giving me run time error now
and the code i have posted earlier is giving time limit exceeded error.
above codes are my two logics to solve the problem.
I've finally had a chance to test your code--sorry for the delay!
Both versions of your code build, run, and work as expected for me... I don't see any runtime errors. Have you tried running them yourself, i.e., not through the site you're using to check your solution?
Again, posting the specific text of this mysterious runtime error would be a big help.
Please post the specific runtime error you're getting
And the error message is... ?
Two questions:
Form1()
?You only have one counter. If you want to count different values in the array, you need a counter for each value.
Please post the specific runtime error you're getting and also your code; we can't help if we don't know what you're doing.
Well I was wondering about a better way to do it, the logic gets all confusing using the FSM :(
The state machine is definitely overkill. I don't have code for you since you're using a custom keystroke detector, but the general idea still works:
bool shiftDown
).In the past I used a "Finite State Machine" to follow a sequence of keystrokes to completion, but I don't think it's effective and I was wondering how you guys would implement this:
(I have the keyboard & mouse hook lib worked out)
When a sequence of events (keystrokes & a mouse-click) occur I need to do something while the mouse button is held down. When I used the FSM it was complicated and somewhat hard to debug.
Events = ctrl + shift + lmb down ... lmb up
lmb up ends the sequence.
any ideas?
It appears that you're just looking for an unordered combination of keys, i.e., the order of CTRL and SHIFT shouldn't matter, it's only important to know if they were down when the left mouse button was pressed. Is that right?
If so, then I would agree that a state machine isn't the best way to handle this--they're fine for ordered keystrokes, but as soon as order doesn't matter, you end up with a whole mess of states to deal with every possible order the keys could be pressed. Bleah.
I would track the up/down state of CTRL and SHIFT independently, and when handling to the mouse button down event, check to see if they're both pressed. If they are, then we've reached the special "do something" condition. You just need a single bool
to track whether you're in the special condition.
If you're doing this in a Windows Forms application, have …
Hey, gusano79 I'm not quite sure how to do that. Plz reply with a code snippet.
Try to read and understand the documentation I linked; all of the information you need is there.
A slightly more detailed example:
fd=open("test.wav", O_RDWR|O_CREAT|ios::app, 0644);
if(fd == -1)
{
// The open failed; do something useful.
}
else
{
// The open succeeded; go ahead and write the data.
write(fd,buffer,len+8+16+8+8);
close(fd);
}
Insert your own code after the "do something useful" comment--it should at least report the error to the user.
Not only my database is on a Linux server, but also my files are.
So, is it possible to build a Windows application using C# and connect it to a server the operating system of which is Linux??
Short answer: Yes.
The OS of the database server shouldn't matter; you'll be connecting over a network anyway. Connector/Net makes it relatively painless to connect to a MySQL database from a C#/.NET application.
Files may be a little trickier; see this post on SO for some ideas.
if I input 3 combinations and complete 'em right, I am not getting 100%. Getting only 99%. Why?
If I count it on calculator it makes 100/3=33.3333333*3=100
It sounds like you're running into floating point accuracy issues in this line:
int percent=(100/combinations)*rightAnswers;
If the actual value of (100/combinations)*rightAnswers
is less than 100.0, the conversion to int
truncates the fractional part.
If you make percent
a floating point value instead of an integer, you can see the actual answer returned, which I expect looks something like 99.9999991892311047981203 (or whatever, I made up those digits). If you use the round
function from math.h
, that should fix you up.
I've never used a vector image as a form background; it might have to do with that. Anyway, I'm glad it's working now!
It doesn't even lag a tiny bit. It's that little image. Do you think if i create the same image in visual studio would it stop lagging?
Hm. I just created a small bitmap outside of VS and tiled it on a form... and there's no performance issue. Are you able to send the bitmap? I'd like to see if it does the same thing for me as it does for you.
Ack, sorry! :) Well, that's information, anyway. Does it run okay if you remove the background image?
Hm. Have you tried running your application on another computer?
It's a secret project, i can't send it sorry
Fair enough :)
i think its something to do with redraw idon't much about it but i heard that when u resize the form it redraws
I think you're on the right track there.
the background is tile and size of the tile is 10 X 10 and there a 6 images size of 24 X 24 so its really small indeed
Just to see what happens, try setting your background image layout to something other than "Tile". If that speeds it up, then drawing the tiled image is probably what's slowing it down.
Trying to tile such a small image actually might be the issue--if you need a faster tiled background, you might try tiling a larger image out of the small one in Photoshop first. That would reduce the number of background images the form is actually trying to draw.
It sounds like color conversion is happening somewhere between the file and your screen. I see you aren't specifying color depth for your display--I don't remember what Allegro defaults to, but it's possible that your display surface and the bitmap have different color settings.
I didn't say code, I meant the project, as in zip it and post it. That seems the easiest way to help figure out why this is happening.
Meanwhile, some questions:
Thanks for reply.But please explain how I produce asm code through that command.I mean where to put that command in c::b , as I always use "run and build" button.
"Project" menu > "Build Options..." item > "Compiler settings" tab > "Other options" sub-tab > Add compiler options to the text area.
What you type in depends on your compiler. If you're using GCC, try "-save-temps"--it will both compile your program and preserve the generated assembly files.
Can you post the project? It's hard to diagnose "going weird".
Have a look at the ComboBox.SelectedIndexChanged event.
You can create an event handler for this event to determine when the selected index in the ComboBox has been changed. This can be useful when you need to display information in other controls based on the current selection in the ComboBox. You can use the event handler for this event to load the information in the other controls.
I've been debugging like crazy and I've come to the conclusion my problem at hand is
190: char *nString = (char*) malloc(sizeof(char));
That line only allocates enough memory for a single character. Is that what you want?
The readme on the fnv hash page lists an example usage:
//For example to perform a 64 bit FNV-1 hash: #include "fnv.h" Fnv64_t hash_val; hash_val = fnv_64_str("a string", FNV1_64_INIT); hash_val = fnv_64_str("more string", hash_val); // Produces the same final hash value as: hash_val = fnv_64_str("a stringmore string", FNV1_64_INIT);
...
I have not encountered anything that explains why you would send the previous hash value to calculate the next.
I'm not familiar with the specifics of the FNV hash, but looking at the code you quoted, here's what I think is going on:
In your example code, the fnv_64_str
function takes two parameters; first, the string to hash, and second, an initialization value. This appears to be representative of the internal state of the FNV hash function, which also the result that is returned from the hash.
The first call to fnv_64_str
starts with an internal hash value of FNV1_64_INIT
, which you can consider a sort of "null hash"--I would expect this value to be returned if you tried to hash the empty string ( ""
). Then for each character in the string to be hashed, it updates the internal hash value, until it reaches the end of the string, then it returns the internal hash value.
So the two-line example is just a way to show you can "interrupt" the hash and finish it later. This might be useful, for example, if you're hashing some sort of input stream as it comes across a network connection, …
if I have a new linked list element I would like to hash into my array, my hash array size must be 2^(Bit size of hash)?
Conceptually, yes... your hash table should be able to accommodate every possible hash value.
In practice, though, you wouldn't normally allocate the entire hash table at once. This can work for short hash functions, but (for example) a 32-bit hash table storing 32-bit pointers would need (2^32)*4 bytes = 16 GB of storage. Hash tables are typically implemented using some kind of dynamic array.
--smg
I would take that to mean that the hash function has two operating modes, one that produces a 32-bit hash, and another that produces a 64-bit hash. The FNV hash you linked actually has six different hash lengths.
Better terminology might be that you have a family of hash functions that represent the same basic hashing technique, and the individual hash functions are variations that produce different hash sizes.
Oh, okay... I see what I missed there:
there's another table called Schools
So to make sure I understand, you're modeling these things:
Ignoring databases, tables, and relationships for a moment, are these the actual objects you're modeling?
Maybe it's poor design? Is there a better way to do this maybe?
Am I going about this the wrong way? Do I need two tables instead? One to store Children addresses and one to store School District addresses? Seems silly to do that considering they really would have the exact same columns?
These are the questions I'm working toward answering. Before we can comment on whether your data model is appropriate, we need to understand what you're modeling.
--smg
Maybe it's poor design? Is there a better way to do this maybe?
I need to have relationships set up similar to this:
One "Parent" can have many "Children"
One "Child" can have many "Addresses" (amuse me, it happens)
One "School District" can have many "Addresses"Am I going about this the wrong way? Do I need two tables instead? One to store Children addresses and one to store School District addresses? Seems silly to do that considering they really would have the exact same columns?
Right, you wouldn't want to duplicate the table just so both schools and districts could have addresses.
I have a few thoughts about your data model, but before I write anything out, it would help to know a bit more about what you're modeling.
The actual objects you're modeling appear to be:
Is that right so far?
Some questions that may be important to the data model:
There are some examples in the web, but they say that I have to generate a .dot file and compile it. Is there a way to do what I want?
Yes. You'll have to write code to create a DOT file (which is just text) that describes your tree, and then run GraphViz externally (e.g., using system()
). That shouldn't be too hard to set up.
I think this is a limitation of openAL not working in Dev Cpp
I don't think so... it seems more like the linker simply can't find the library. Can you post your entire build output?
Also, this is a little redundant:
if (encontrado==NULL)
printf(" data already exists");
else
if (encontrado!=NULL){
pos=buscar_nodo(&(*r), dato);
}
As Vernon points out, you've already tested encontrado
, so there's no need to do it again:
if (encontrado==NULL)
{
printf(" data already exists");
}
else
{
pos=buscar_nodo(&(*r), dato);
}
Code::Blocks isn't working. I recently reinstalled to get a newer version and when I hit build I get the following error:
mingw32-g++.exe -Wall -g -I"C:\Program Files\CodeBlocks\MinGW\include" -c D:\Programming\C++\TESTINGOPENGL\main.cpp -o obj\Debug\main.o Execution of 'mingw32-g++.exe -Wall -g -I"C:\Program Files\CodeBlocks\MinGW\include" -c D:\Programming\C++\TESTINGOPENGL\main.cpp -o obj\Debug\main.o' in 'D:\Programming\C++\TESTINGOPENGL' failed.
Please help!
Details? Which version of C::B were you on, which version did you switch to? Is this all of the output you got, or were there other messages?
how much time needed to have a command over openAL ? ok, I will check the sufficient help for loading audio files in my project...but I want to learn it from scratch...Sometimes I read others source code..but I am worried about why this process didn't come in mah mind...have a feeling of rememorize it.. lot of questions in mah mind.."how ?" and "why ?"..if you have any idea about a tutorial ..plz post those links....thanks !!!
OpenAL doesn't seem too hard to me, but I came to it with a lot of background in sound processing and playback, so your mileage may vary.
I'm not aware of any basic tutorials, but the documentation by Creative Labs should be useful, especially the Programmer's Guide and the ALUT Manual.
Is FLEX dealing with regular languages or regular expressions, and also what is the difference exactly?
A regular language is, by one of many definitions, a formal language that can be described by a regular expression. Regular expressions are a convenient way to describe a regular language without having to specify all of the sequences that are in the language. This is convenient when the language is infinite.
Flex generates code that checks an input stream to see if it matches any one of a list of regular expressions.
Could you give an example of how a flex program works and or point me to a link that does? How it integrates with C++?
The Flex manual is a good place to start; it has some simple examples near the start.
Flex generates a C source file with the scanner definition and assorted support code. This should work with a C++ program as is, but there is also experimental support for generating a C++ scanner.
The type 'T' must be a non-nullable value type in order to use it as parameter 'T' in the generic type or method 'System.Nullable<T>'
Key phrase: "non-nullable value type"
So T
can't be a reference type (i.e., a class), and it can't be a nullable value type (e.g., int?
).
You have to limit T
to be a structure:
private SqlParameter op<T>(T? t, string name)
where T : struct
{
// do stuff
}
You're looking for the RichTextBox control.
Pro tip: Search the forums. See this post for an example of multicolored text in a RichTextBox.
Okay! Where are you getting stuck translating this to assembly? Also, which assembler are you writing for?
Let's forget the "using assembly" part of the question for a second... do you have an idea of how to count the zeros in an integer at all? Please give us what you've come up with so far.
One way to do this is have a static field in the Student class to keep track of what the next ID should be. Then, every time you create a new Student object, use that value and increment it so the next Student gets the next ID, and so on.
Like this:
class Student
{
private static int nextID = 1;
public int ID { get; private set; }
public Student()
{
ID = nextID++;
}
}
You're trying to do it all at once, but it's easier to write if you split it up into parts.
First, check to see if the display orders are both positive or both negative. If they aren't, then return that the positive one is "less than" the negative one. If they are, then just use the standard comparison. If you want the negative ones to go {-1, -2, -3, ...} you'll have to reverse the comparison when they're both negative.
Like this:
if(col1.DisplayOrder == col2.DisplayOrder) // Equal.
{
return 0;
}
else // Not equal.
{
bool col1neg = col1.DisplayOrder < 0; // Column 1 negative?
bool col2neg = col2.DisplayOrder < 0; // Column 2 negative?
if(col1neg != col2neg) // One negative, one positive.
{
if(col1neg) // Column 1 is negative, column 2 is positive.
{
return 1; // Negative is always after positive.
}
else // Column 1 is positive, column 2 is negative.
{
return -1; // Positive is always before negative.
}
}
else // Both negative or both positive.
{
int c = col1.DisplayOrder.CompareTo(col2.DisplayOrder);
if(col1neg) // Both negative.
{
return -c; // Compare reversed (so you get -1, -2, -3, ...)
}
else // Both positive.
{
return c; // Compare normally
}
}
}
Compact version:
if(col1.DisplayOrder == col2.DisplayOrder) return 0;
else
{
bool col1neg = col1.DisplayOrder < 0;
bool col2neg = col2.DisplayOrder < 0;
if(col1neg != col2neg) return col1neg ? 1 : -1;
else
{
int c = col1.DisplayOrder.CompareTo(col2.DisplayOrder);
return …
I need to find the length of a long variable (how many numbers it holds). So if the variable holds: '1234567890' then I want to return an int value
of '10'.
One way to do this is with Math.Log10. There's a trick to getting the right answer, though... look at the example output on the linked page for clues.
I've been trying to find information on this everywhere for quite some time now. I want to build DLL plugins for my application, but don't want to implement them at basic run time. I want the user to be able to import them through an open file dialog. Any help on this topic is appreciated.
I'd suggest you start by getting familiar with application domains and the AppDomain class. There are various "how to" articles linked in both of those pages that should get you going.
Here's a start: Instead of just declaring one line ( DLine line;
), why not make it a list of lines ( List<DLine> lines;
)?
I attached the dll that was given to me for this project. As well as the instructions that were given to me for completing this project since I realize I'm not being very clear. Thanks again for your help!
Ah, okay, now I see what you're getting at.
All you need to do is create a new RobotCollection
. Then use its FindByName
method to find robots matching the names users search for, and each Robot
the method returns has a ConnectsToRobots
property that tells you which other robots are "connected" to it.
That should be all you need to get the data for your assignment.
I've been using .net reflector to decompile it, but haven't had any luck figuring out which class can help me pull the data out of the DLL. I'm just trying to find if anyone has any experience pulling data (names of products, prices, etc.) out of a DLL file and if so how they managed to do it. I understand that it would likely be specific to each DLL, but a starting point would be very helpful!
The conversation here has been very generic so far, and I wouldn't expect to get much help without more detail. Some amount of system knowledge and being able to identify patterns will both help. Are you able to post the assembly in question? Reverse engineering, at least in my experience so far, is a very hands-on kind of task.