Labdabeta 182 Posting Pro in Training Featured Poster

True, that should work... theoretically. The big issue is that since they moved it, it uses dynamic positioning based on window size. So I would have to do that on every WM_RESIZE event. However I suppose that the user shouldn't be resizing their window all that frequently, so I guess your solution is sufficient.

Labdabeta 182 Posting Pro in Training Featured Poster

Basically GetPixel takes a window and returns the colour of the pixel that is x to the right of the left of the window and y to the bottom of the top of the window. For more info http://msdn.microsoft.com/en-us/library/windows/desktop/dd144909%28v=vs.85%29.aspx

Labdabeta 182 Posting Pro in Training Featured Poster

I have a program using old data for a game I play to indicate which pixels correspond to the health bar in my game. (my program just loops until a button is clicked and presses a key if the health bar drops too low). Unfortunately the health bar has moved and the people that measured where the health bar was have stopped caring. I am wondering how do you find out exactly which pixel to watch in GetPixel based on a picture of the game. I tried opening it in GIMP and using the measure tool, but found that the top left pixel was rather fuzzy. Is there any easier way to do this? (Like maybe some program somebody could either write or explain to me how to write that would do exactly what I need)

Labdabeta 182 Posting Pro in Training Featured Poster

Perfect answers. I think I will use fstream (for ease, and portability [I assume that if win32 api gets depricated that fstream will probably be one of the first to be 'fixed']) I will open 1 file per integer while keeping track of how many integers are in existence (something I already do). If that number goes over FOPEN_MAX I will close all of them and then only open them while needed. As for the recursive files for really really big numbers, they will already take FOREVER to work with, so the slight overhead of opening and closing a file really shouldn't be noticeable. Thank you for the help :)

Labdabeta 182 Posting Pro in Training Featured Poster

Hello,

I made an arbitrary precision integer library a few weeks ago. It works well, but is bounded by 256^(8*sizeof(size_t)) because it uses a simple dynamically allocated array to do its work. I want some way to have theoretically unbounded storage. I think that file io is probably best, but then I realized that stdio functions (and thus their fstream counterparts) use size_t to indicate the position in a file, so at best I will merely double the number of bits I can store. As such I thought of a format that would in a way 'cascade' files in the following way:

Typical file: +/- (indicates sign), data stored in little-endian, base-256.

File for really really big numbers: f (indicates that this is a file of files), list of files that represent integers, in little-endian base 115792089237316195423570985008687907853269984665640564039457584007913129639936 (256^32 if wolfram is to be believed).

My issue is that this will take a LOT of work to incorporate, and I want to know that it will work. I also have questions concerning implementation. For example, when a number gets too big to be stored as a dynamic array I want to shift it to a temporary file in the above format. However, since this is an active number I would like to keep the file structure open so that I don't have to keep opening and closing it. The issue is that as far as I know, its when you close the file that you actually save it.

My first question …

Labdabeta 182 Posting Pro in Training Featured Poster

Ok, I fixed the dot issue with an optimized version of the bresenham algorithm. I also resolved the lag by 'flattening' my surfaces earlier so that rather than blit a bunch of small surfaces on to the big one seperately, I combine them and blit them all at once. IE if A,B,C,D,E are surfaces that I want to put onto F then I would do:

A+B=AB
C+D=CD
AB+E=ABE
ABE+CD=F

which brings the number of combinations onto my large surfaces (the big two being the image and the screen) way down. Thanks for the help though.

Labdabeta 182 Posting Pro in Training Featured Poster

Hello,

I recently wrote a program that I wish to be portable (IE: no installer, just raw files). I have made an icon for the program and can attach it to a shortcut, but not to the executable itself (it stays as the default). On top of that I have set .cbs files to open with my program (since it is designed to edit them), however it changes their icon to an ugly default icon and I would rather that it associate my icon with them. How can I make these icon associations?

Labdabeta 182 Posting Pro in Training Featured Poster

Could you name one such analysis tool? Also when it comes to the making of dots rather than lines I am well aware of the issue, its that the mouse can move more than 1 pixel in a single frame. I think the solution is to somehow interpolate a line from where it was in the previous frame to where it is in the last frame. I just don't know an efficient way of doing this. I was thinking of using a bresenham algorithm to plot the center points along the route and then plot a circle of the correct radius at each generated point. This would create the desired effect, but I fear it may be very slow since most mouse movements are 1-3 pixels and drawing 3 circles when 2 would suffice seems like a waste. I am wondering if there is some way to optimize that issue.

Labdabeta 182 Posting Pro in Training Featured Poster

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 the step function. How long does SDL_BlitSurface take? Also the step function returns the image that I want to blit to the screen, as such I call SDL_BlitSurface to blit its return value to the screen surface. How much time would I save by passing the screen surface to my step function so that it can blit directly to the screen. Finally, the program works by drawing small circles at the cursor position every time step is called while the left mouse button is down. Unfortunately if you move the mouse fast enough you can cause small dots to be drawn instead of a continuous line. From testing I found that it seems like MS paint seems to draw a line from point A to point B when that happens, how can I do this fast enough to make it worthwhile? If you need any sections of the code just tell me.

Labdabeta 182 Posting Pro in Training Featured Poster

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 is assumed to be an r-value. Basically this means that it will act identically to what would happen if you swapped out the function with its return value. Returning the reference changes the return value into an actual variable rather than a value. Here is equivalent code for both situations:

int fun()
{
    static int x=10;
    return x;
}
fun()=30;//this will become:
10=30;//which is obviously an error! 

//however:

int &fun()
{
    static int x=10;
    return x;
}
fun()=30;//this will effectively become:
fun_x=30;//note that fun_x is actually the X inside fun.
Labdabeta 182 Posting Pro in Training Featured Poster

Exactly what I was looking for. Thank you guys :)

Labdabeta 182 Posting Pro in Training Featured Poster

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; ++i)
    for (int ii=0; ii<256; ++ii)
        fout<<(unsigned char)i<<(unsigned char)ii;

And the same argument would obviously extend to any length of the eof flag. I am wondering if there actually is a way to (accidentally or not) create a false EOF flag. I mainly wonder because I am trying to define a file format for some of my classes to save their data to a file and I am noticing that most 'official' files start off by listing their size in some way or another, and I am wondering if that is to help define where the EOF is.

Labdabeta 182 Posting Pro in Training Featured Poster

Some descriptive comments (in english) would be very helpful. Your variable names are hard to decode. Rename your variables so that they explain what they are, and use comments to describe your code. Also I would strongly recommend splitting your code into functions, for more legibility.

Labdabeta 182 Posting Pro in Training Featured Poster

In his first post he did say that it was about the different compliment systems (he misspelled them but he meant Digit and Radix complements) Digit complement in binary is 1s complement, whereas radix complement in binary is 2s complement. Here is -3 stored in a 3-bit number in both:

Digit complement (1s complement):
original is 011 (3), invert all bits to get 100 (-3)

Radix complement (2s complement):
original is 011 (3), most significant bit is negative so 111 is -1, so 101 would be -3 (by subtracting the 2 bit)

The issue is that I can't access his code. If you can could you post it directly here rather than using pastebin?

Labdabeta 182 Posting Pro in Training Featured Poster

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 such you can think of Constructors and Destructors as functions that the compiler automatically inserts. Here is an example:

class TestClass;
//We are going to pretend that TestClass's constructor is actually this: (its not too far from the truth)
TestClass TestClassConstructor();
//and that this is its destructor:
void TestClassDestructor(TestClass tc);
//The compiler is going to replace this line:
TestClass myTestObject;
//with this one:
TestClass myTestObject=TestClassConstructor();
//and when it goes out of scope like in this example:
{
    TestClass test;
}
//the compiler will have to call the destructor
{
    TestClass test=TestClassConstructor();
    //out of scope time, must destruct!
    TestClassDEstructor(test);
}

You can see how since the compiler automatically tries to call the constructor and destructor in a very public way it runs into issues if the constructor or destructor are private. This allows you to do some interesting things. Lets say that you have a class to hold a fraction and you only want to allow people to make it with a constructor that specifies its numerator and denominator. You could do it this way:

class Fraction
{// private:
    int numerator,denominator;
    //Since this constructor is private it cannot be used outside the class
    Fraction();
    public:
    Fraction(int num, int …
Labdabeta 182 Posting Pro in Training Featured Poster

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 to do.

Labdabeta 182 Posting Pro in Training Featured Poster

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' button to bring the hour back down. As such I want to construct an up-down counter that would increment on the rising edge of one input and decrement on the rising edge of another. I have one that increments on the rising edge of the clock if the extra input is 1 otherwise it decreases with the clock. The issue is that I need to convert this to what I want. I have tried the following, but it didn't work. Is it merely an issue with my simulator? or do I need a better solution?

The circles at the top are outputs, the squares at the bottom are the reset inputs. The square chips are positive edge triggered toggle flip flops with set marked as 1 and reset marked as 0. The unmarked rectangles are signal splitters (left is on when the input is 0 and the enable line is 1, right is on when the input is 1 and the enable line is 1).

Original Clocked version: (top is the increment input [incrementation happens iff it is 1] bottom is clock)

a9e0baadd39b06c8ec35ed255cebab15

My attempt at unclocked version: (right is increment on rising edge, left is …

Labdabeta 182 Posting Pro in Training Featured Poster

Will do, thanks :)

Labdabeta 182 Posting Pro in Training Featured Poster

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 found a decent forum on which to post questions.

Labdabeta 182 Posting Pro in Training Featured Poster

I think you are still getting the errors because you are still trying to use polymorphism. If you use the const AbstractType & (inheritance) technique then you don't even need the <DefinedClass> at all. Also you don't need a pointer! Just this is how you use it:

DefinedClass dc=new DefinedClass;
new FileWritter("filename.file",dc);//it gets referenced automatically!

Also it seems as though in your definition of FileWritter (in FileWriter.h) you didnt define the functions you are trying to use. So here is a translation of your errors:

C4430: You didnt provide a type inside the <> section of your class... we're gonna assume you want ints. (fix this by just not using templates... they aren't correct here!)

C2143: Since it is still waiting on the <> section it gets confused when you throw in an & sign. Same fix as before.

C2509: What are you trying to pull? You didn't tell us you were making a constructor for FileWritter. You can't make an outside of class definition of something not already in the class. Example:

class Test
{
    public:
    void myFunctionA();
};

//This works, because the compiler knows that there is a myFunctionA inside Test
void Test::myFunctionA()
{
    //dosomething
}

//This doesn't work, because the compiler wasn't told in advance that this would be here!
void Test::myFunctionB()
{
    //dosomething
}

C2955: Again... when are you going to give us the <>... we have no idea what we are dealing with!

C2509: Again... you never told us you were …

Labdabeta 182 Posting Pro in Training Featured Poster

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 AbstractClass
{// private:
string exampleData;
public:
AbstractClass();
virtual string getData()const{return exampleData;}
virtual void setData(string &o){exampleData=o;}
};

ostream &operator<<(ostream &left,const AbstractClass &right)//this should work for any class that inherits from AbstractClass
{
    left<<right.getData();
}

class FileWriter//there is only one 'T' in writer
{// private:
    ostream file;
    public:
    FileWriter(string fileName, const AbstractClass &ab){//MUST BE A REFERENCE OR POINTER!
        file.open(fileName.c_str());
        file<<ab;
    }
    ~FileWriter(){
        file.close();
    }
};

And here is the template based solution:

template <class AbstractClass>
class FileWriter
{// private:
    ostream file;
    public:
    FileWriter(string fileName, const AbstractClass &ab){//Abstract class must implement ostream&<<AbstractClass&
        file.open(fileName.c_str());
        file<<ab;
    }
    ~FileWriter(){
        file.close();
    }
};

Here are example uses of each:

Inheritance method:

class myClass:public AbstractClass
{};//normally this would have something in it. And it can modify get/setData to change its output behaviour
myClass mc;
FileWriter fw("myFile.txt",mc);

Template method:

class myClass
{};//normally this would have something in it. And it can modify the following function to change its output behaviour
ostream &operator>>(ostream &left, myClass &right)
{
    left<<"This is a myClass";//for example
}
myClass mc;
FileWriter fw("myFile.txt",mc);
Labdabeta 182 Posting Pro in Training Featured Poster

Well that is the issue with the hare psychopathy checklist. Its a decent way to get an estimate of the psychopathic levels of a person, but it is by no means conclusive. It is far to easy to cheat, and it doesn't necessarily cover everything you need to know about a person to determine if they are a psychopath. The only way to find out if you are a psychopath is to go to a real psychologist and have them run the real tests, which often involve long answers, not just yes/no. I know this because I have been to many psychologists before. As such these checklists are more for getting a ball-park estimate of your chances of being a psychopath than anything else. (There is a similar issue with all the free Meyers-Briggs tests out there, the real one involves an influx of information and then a trained professional sorta 'measures' your processes when confronted with the information).

Labdabeta 182 Posting Pro in Training Featured Poster

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 get each element one at a time [like inputs from stdin]), merge (which I use for optimality), and heap (which I don't use too much because I happen to prefer merge :) ). Anyways, I hate writing code that is not optimal. That is why for example when I am doing Project Euler problems I always solve them for the most general case, as well as I can. Typically either insertion or merge sort are ideal, but I have just begun a project that will involve sorting an entire dictionary that may or may not be mostly pre-sorted. As such I was hoping for a more efficient algorithm. Since I expect the dictionary to be possibly pre-sorted, but possibly unsorted I looked into timsort and smoothsort. Since identifying runs sounds complicated I thought I would learn smoothsort. The issue is that the wiki explanation is quite complicated and confusing. I am wondering if anybody can explain smoothsort better and perhaps provide a pseudo-code implementation. Thank you.

Labdabeta 182 Posting Pro in Training Featured Poster

This website is an open forum in which we discuss any and all topics related to the world of information technology. If you want to know more I would suggest creating a new thread. One thing you should know is that this website hates it when you awaken sleeping threads (if you look at the post before yours it was submitted a year ago... this thread was sleeping).

Labdabeta 182 Posting Pro in Training Featured Poster

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.

Labdabeta 182 Posting Pro in Training Featured Poster

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. That way you get the local this calls and only need to 'return' the values that you need through getters and setters. As such in my opinion the solution I would use is this:

class somethingDescriptive
{ //private:
    int row_locs, col_locs;
    int row_descriptors, col_descriptors;
    double **locs;
    double **descriptors;
    public:
    somethingDescriptive();
    void someFunction();
    int getRowLocs();
    int getColLocs();
    int getRowDesc();
    int getColDesc();
    int locs(int x, int y);//assuming locs is a 2d array
    int descriptors(int x, int y);//same assumption
};

Or something similar. Another option is to combine locs and descriptors into something like this:

struct Cell
{
    double loc,desc;
};
struct DimensionSpecifier//im assuming still that locs/descriptors are 2d arrays
{
    int row,col;
};

void someFunction(DimensionSpecifier &ds, Cell **cells)
{
    //todo
}

Basically in most situations other than massive projects if you have enough parameters that this is an issue, you probably have too many parameters.

Labdabeta 182 Posting Pro in Training Featured Poster

http://www.cplusplus.com/forum/articles/416/

Basically when you dynamically allocate an array the compiler calls the constructor for each object you want to allocate.

Labdabeta 182 Posting Pro in Training Featured Poster

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];

Now look at your code. This is a section of it:

double exam1[NUMBEROFSUDENTS];
double exam2[NUMBEROFSUDENTS];
double exam3[NUMBEROFSUDENTS];
double exam4[NUMBEROFSUDENTS];
double exam5[NUMBEROFSUDENTS];

Look familiar? The solution to this is to make an array of arrays:

double exam[NUMBEROFSTUDENTS][5];

That solves your problem with the uglyness of your code. Now onto the problem of it not being right. I feel like you are not fully understanding how classes work. The whole point to a class is so that you don't have to send it all those arguments for all of its functions. Instead you can store them inside the class and then the compiler basically passes them for you! This means that this whole section is just wrong:

class student
{
public:
void setGrades(int studentId[], double exam1[], double exam2[], double exam3[], double exam4[], double exam5[], int count);
int getGrades(int studentId[], double exam1[], double exam2[], double exam3[], double exam4[], double exam5[]);
void error(int studentId[], double exam1[], double exam2[], double exam3[], double exam4[], double exam5[], int count);
void average(int studentId[], double exam1[], double exam2[], double exam3[], double exam4[], double exam5[],
double total[], int count);
void newAverage(double exam1[], double exam2[], double exam3[], double exam4[], double exam5[], int …
Labdabeta 182 Posting Pro in Training Featured Poster

That is helpful, but I prefer to be able to make something work from scratch before using a library to make it easier. I'm sure I could do what I want with that library, but I wouldn't understand what it was that I was doing. I would prefer an explanation (or a link to an explanation) of what sockets are and how to use them. For example in the first example on that site you sent me they have a line like this:

s.SendLine("GET / HTTP/1.0");

I think I understand that its sending "GET / HTTP/1.0" to the server that the socket is linked to, but what does "GET / HTTP/1.0" mean? How did they know that that is what they wanted sent?

Labdabeta 182 Posting Pro in Training Featured Poster

I have never been able to understand sockets... I have tried a couple of tutorials, but understanding them always seems to elude me. Could you maybe point me to a decent tutorial for them, and maybe explain exactly what they are? Thanks.

Labdabeta 182 Posting Pro in Training Featured Poster

Ok... it turns out code::blocks kinda sucks with stand-alone assemblers. It always wants them to shove the assembly code into a library rather than just execute it. So I guess I will write my code in the editor (for syntax highlighting, etc) then assemble it on its own. OllyDbg looks decent, but I really like MSCodeView's interface. Is there any way to use it with NASM instead of MASM?

Labdabeta 182 Posting Pro in Training Featured Poster

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 for me to use the daniweb api to make a kind of editor in c++. I want to use c++ because it is what I am most familiar in, if it is overly complicated in c++ please tell me what language it wouldn't be complicated in. Anyways I just want to know how to use a web api in c++.

Labdabeta 182 Posting Pro in Training Featured Poster

Wow, NASM seems perfect. One more issue, currently all that I know about assembly I learnt from http://www.intelligent-systems.info/classes/ee360/tutorial.htm . I am wondering if there is a decent debugger that could (maybe?) work with the code::blocks debugger. I understand that that is unlikely, so really any good debugger would be awesome. Thanks :)

Labdabeta 182 Posting Pro in Training Featured Poster

It seems like writing a program to convert from Intel to AT&T and back again wouldn't be very hard. Is it possible to get an Intel style assembler to work with Code::Blocks. And if so where could I download it? All I want to be able to do is run this: someAssembler.exe mySourceFile.asm myOutputFile.exe. As of right now I am using an odd... thing... It converts asm code to c code then compiles it... IMO it sorta defeats the purpose of assembly, no? Anyways a simple executable that works on simple command line arguments would be perfect.

Labdabeta 182 Posting Pro in Training Featured Poster

I don't have any experience with non-web based languages

And I only really have experience with non-web based languages. But I saw my friend write a program in python using a c library to access our university's API and he made a decent app with it. Since it was a simple static linked c library I know that it must be possible, I just have no idea how. I am certain that somebody on this forum knows how to do such a thing. Its just a matter of having them see it. I am wondering if I should post here, or in Software Development to get the help I need.

Labdabeta 182 Posting Pro in Training Featured Poster

I have not yet decided... but I would like one that will work well with code::blocks. It already does ASM highlighting, it can't be too hard to find an assembler that will work with it. What do you suggest? All I need is something that can be used at run-time (not a hard thing to ask) as I have already made my own pseudo-compilers from certain esoteric langages to c/c++ and C::B compiles them just fine.

Labdabeta 182 Posting Pro in Training Featured Poster

One thing you can do is swap the order of your counts. Giving them descriptive names could help. For example:

int myArray[height][width]={0};//or whatever
for (int x=0; x<width; ++x) //loop through x SECOND! (since this is the outside loop)
{
    for (int y=0; y<height; ++y) //loop through y FIRST! (check it by hand if you don't believe me)
        doSomethingWith(myArray[y][x]);
    //do things that happen once per x here 
}
//If you want to loop by x first, then y:
for (int y=0; y<height; ++y)
{
    for (int x=0; x<width; ++x)
        doSomethingWith(myArray[y][x]);
    //again... do things that happen once per y here
}

As such your problem I think would be the ordering of your loops. Also I never use iomanip, iostream has everything you need for this. Google for the manip functions of cout... I don't know them off-hand. (or maybe somebody will lend their memory here instead).

Labdabeta 182 Posting Pro in Training Featured Poster

I currently suck at web-based stuff, but I have been wanting a modified interface for awhile, I am talking with a friend of mine who is very into web-based stuff to help me out, but my main concern is that neither of us is experienced enough to get my idea working well fast enough. I am wondering if anybody can describe the process by which I could make a PC program (just an exe file) that could access the data on daniweb, present it differently (IE: I want to highlight any post in which the last post was made by the creator) then edit it differently (IE: a built-in editor that could execute simple code examples to test and ensure that they work, and could allow for custom syntax highlighting). I would know how to make such a program if all the daniweb data was kept on a hard-drive on the users machine, but obviously it isn't. From what I understand an API is designed to allow similar access to the data that is NOT on the hard drive but rather here on daniweb. Unfortunately when it comes to the internet I never know what to do. (I would like if I could access the API functionality in c++/WinAPI, but java or similar would work as well) If it can't be done easily via a c-style language HTML would work too, I could implement my idea as a website without taking a major hit, but again, it would be less …

Labdabeta 182 Posting Pro in Training Featured Poster

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 in c++ (NOTE: integer division!). The answer is 0. That is why its all writing 0s. If you want the original array then don't divide by totals, if you want the fractional value then try (double)values[count][count2]/totals so as to call floating point arithmetic.

Labdabeta 182 Posting Pro in Training Featured Poster

So it seems that what computer you are using and what assembler you pick determines what dialect you will be writing in... if that is the case how do I find a tutorial for MY computer and MY assembler?

Labdabeta 182 Posting Pro in Training Featured Poster

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 questions are:

A) Did the assembler simply copy-paste the library code in (like a header file in c/c++)
B) Where can I learn general assembly?
C) I noticed that pretty much every tutorial uses different layout (IE: data:code: vs section data, etc) what are these and how can I know which one is correct?
D) I always hear that you need to specialize your assembly code to your exact operating system, but then how come I can run certain programs across all the systems? What sort of sorcery is going on?!

Labdabeta 182 Posting Pro in Training Featured Poster

So in summary you are saying that for my purposes a static library, compiled with not MSVC (which is fine since I use either MinGW or g++ depending on situation) would probably be best. Then all I need to do is include my header files and link to my library to get access to all my functions? And I can also have a global variable or two in the header file that my library functions can access?

Labdabeta 182 Posting Pro in Training Featured Poster

Sorry about the massive question load, I just really want to ensure I understand. What you are saying is that a DLL with a properly written c-interface can have its functions (or classes if in c++) called by pretty much any language that supports calling c functions and on most operating systems, whereas a static link library would only really work for people using MY compiler (or a similar one). If this is true I think I want a DLL despite versioning issues (especially since I can always store the version in a small global variable) since a DLL will allow me to 'always' be able to use the code, although sometimes it may take some work. Particularly I am creating a little 'package' of 3 libraries that contain functionality that I find myself using a lot. I have a graphics library that simplifies my OpenGL work (no more tedious window set-up, etc), an integer library that does arbitrary precision arithmetic on integers (and extends to rationals as well), and a file handling library designed to get the raw data out of compressed or complicated file formats. I want to ensure the following conditions on the libraries:

1) I can use any number of them in any combination without an issue. (IE: I can use the graphics and math libraries at the same time)

2) I can use any number of the libraries with c OR c++. (or it seems even other languages???)

3) I can run any two programs …

Labdabeta 182 Posting Pro in Training Featured Poster

Okay... I am still a little confused. I have written DLLs and SLLs? before, but I never fully understood them. For instance I never understood what extern "C" { does exactly. Also, what do you mean that a .lib c++ constructs are fine? Wouldn't I still have to define c-style ones too if I want it to be useable in c?

Labdabeta 182 Posting Pro in Training Featured Poster

Granted, but Mestral beats you to the patent... now you are that crazy guy that keeps screaming "I invented velcro!"

I wish I had a supercomputer.

Labdabeta 182 Posting Pro in Training Featured Poster

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 entered. I am not sure how you would want to fix this. I would put the input into the do-while loop and forget about the for loop completely. Here is your code with the errors highlighted by comment:

    #include <iostream>
    #include <math.h>
    #include <cmath>
    #include <climits>//for INT_MIN, INT_MAX
    using namespace std;
    int main ()
    {
    float sum = 0.0;
    float sub = 0.0;
    float variance = 0.0;
    float mult = 1.0;
    float mean = 0.0;
    float min=INT_MAX,max=INT_MIN;//create min and max here
    int i;//remove this and change all the i's to n's
    float arrayVal[100];
    int n=0;
    cout<<"input your values"<<endl;
    do
    {//note the removed for loop.
    cin>>arrayVal[i];
    sum += arrayVal[i];
    if (n == 0)
    {
    sub = arrayVal[i];
    }
    else
    {
    sub-=arrayVal[i];
    }
    mult *= arrayVal[i];
    //do not recreate max
    if (max>= arrayVal[i])
    {
    max=arrayVal[i];
    }
    //do not recreate min
    if (min <= arrayVal[i])
    {
    min=arrayVal[i];
    }
    n++; // n represents the number of values input by the user
    }
    while (i<100 && arrayVal[i]!=0);
    mean = sum/n;
    for (i=0;i<100;i++)
    {
    variance += pow((arrayVal[i]-mean),2);//using pow for squaring is sorta lame... (arrayVal[i]-mean)*(arrayVal[i]-mean) is arguably better
    }
    float standDev = sqrt(variance);
    cout<<"Sum = "<<sum<<endl;
    cout<<"Sub = "<<sub<<endl;
    cout<<"Mult = "<<mult<<endl;
    cout<<"Max = "<<max<<endl; …
Labdabeta 182 Posting Pro in Training Featured Poster

Granted, the great war for the moon breaks out.

I wish I invented interstellar flight.

Labdabeta 182 Posting Pro in Training Featured Poster

I know, but it loses its touch when you know enough latin to pronounce it properly :(

Labdabeta 182 Posting Pro in Training Featured Poster

Wow... I had no idea you could do that little struct myClass thing and actually use a class in there for the c implementation. That makes my work a whole lot easier! Also I didn't realize that it was considered 'acceptable' for a c library to make you clean your own garbage, I was trying to find a way to make it so that all my types c or c++ would auto-delete. Anyways, I guess your solution is clearly best... But what exactly are the rules for that... can you just pass a void pointer to the c-style functions and then cast it to a class in the c++ definition of the function? I would have guessed that would be impossible. Anyways I still do not fully understand exactly how the syntax would work... would it be something like this:

//myLib.h
#ifndef SOME_GUARD
#define SOME_GUARD VERSION_NUMBER

#ifdef __cplusplus
class myClass
{
    //privates
    public:
    //publics
    myClass();
    myClass &someFunction();//to better understand how this would work
    int operator[](int)const;//again... for understanding purposes
};
#else
typedef void *myClass;
myClass myClassConstructor();
const myClass myClassSomeFunction(myClass);//since a const pointer can act like a reference if necessary
const int myClassOperatorSubscript(int,const myClass);
#endif

#endif

//myLib.cpp
#include "myLib.h"
myClass::myClass(){/*something*/}
myClass &myClass::someFunction(){/*something*/}
int myClass::operator[](int i){/*something*/}
void *myClassConstructor(){return new myClass;}
const void *myClassSomeFunction(void *x){return &((myClass*)x)->someFunction;}
int myClassOperatorSubscript(int i, const void *x){return ((myClass*)x)[i];}

Then just compile it as a static link library and I'm done?

Labdabeta 182 Posting Pro in Training Featured Poster

I think visa is based on saying "I went" either in latin or some other romance language... as such Vini Vidi Visa is I came, I saw, I went... also quite a common thing in north america :)