Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I have to agree with Terminator1337 on this, the code for the main() function in particular is wretched (not to mention incorrect - in C++, main() should always return an int, with no exceptions to the rule). The fact that it appears to have been given to you by the instructor makes this even less acceptable.

As for the ReduceFraction() function, simply think through how you would do it manually: you first find the greatest common divisor of the numerator and the denominator, then divide them each by said divisor. Simple, no?

Getting the common denominator of two ratios is almost as easy: you multiply the denominators, then multiply num1 by den2 for the new num1, and num2 by den1 for the new num2.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Yes, but it isn't clear why you would need to - it seems to work well enough as it is (modulo a few issues). What other functionality does the program need which would require pointers?

A few things I did note that could cause problems. First off, you have a function named seats(), and inside that function you have a variable seats[][]. While it may not be causing a problem, it is a name collision and you would be well advised to rename one of the two. I would call the function seating() or something like that.

Second, you declare main() as type void, which is incorrect; in C++, main() should always return type int. Don't forget to add a return 0; at the end of main() as well.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Ye gods and little fishes! How many different functions is bhpeqns() computing? This is insane! You must - absolutely must - break this down into separate functions if you stand any chance of understanding and debugging this mess. Trying to interleave multiple functions this way is courting disaster.

What you did with the Hookes-Jeeves function is particularly worrisome, since you took a fairly simple, modular function and made it into a morass of complication. This function should be something that you could apply to several different functions without even knowing the details of the functions it is applied to.

hey thanks for the suggestions and they were very help ful..

I can't see how helpful it was, given that you outright ignored the majority of my advice, and generally misinterpreted the rest.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

At the risk of being presumptuous, I have taken the liberty of breaking the program into separate units, to make it easier to debug the separate parts. I have re-written the functions so that a) the function to be optimized is passed as an argument to the hooke() and bestsearch() functions, b) the vars value are passed to all three functions, and c) the hooke() and bestsearch() functions dynamically allocate their internal arrays, and free them when finished. While the code will compile and run, I do not know for certain if it is correct; you'll need to test it yourself for the correct results.

hooke-jeeves.h

#ifndef HOOKE_JEEVES_H
#define HOOKE_JEEVES_H 1

double hooke(double (* func)(double[], int, const int), const int vars, const int nvars, double startpt[], double endpt[], double rho, double epsilon, int itermax);

#endif

hooke-jeeves.c

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "hooke-jeeves.h"


double bestsearch(double (* func)(double[], int, const int), double delta[],double point[],double prevbest, const int vars, const int nvars);

int funevals = 0;


double hooke(double (* func)(double[], int, const int), const int vars, const int nvars, double startpt[], double endpt[], double rho, double epsilon, int itermax)
{
    double *delta;
    double newf, fbefore, steplength, tmp;
    double *xbefore, *newx;
    int i, j, keep;
    int iters, iadj;

    delta = calloc(vars, sizeof(double));

    if (delta == NULL)
    {
        printf("hooke: Memory allocation error variable delta\n");
        exit(-1);
    }

    xbefore = calloc(vars, sizeof(double));
    if (xbefore == NULL)
    {
        printf("hooke: Memory allocation error variable xbefore\n");
        free(delta);
        exit(-1);
    }

    newx = calloc(vars, sizeof(double));

    if (newx …
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

OK, before I address the issues of the functions themselves, I'd like to look at some technical issues in the code overall.

  • The main() function in both C and C++ should always return an int value; void main() is incorrect except in certain cases in C (and always in C++).
  • The <iostream.h> header is not only obsolete, it is specific to C++; if this is supposed to be a C program, it should not be included here.
  • The headers <conio.h> and <graphics.h> are specific to the Borland compilers; given that you don't actually use them anywhere, you can safely take them out.
  • Similarly, there is no standard <float.h> header, so this can also be removed.
  • Since you don't use variadic functions anywhere, <stdarg.h> can be removed as well.
  • You generally want to put all #define directives before any other code that references the constants. This relates to the next part, where you use a defined constant before its definition.
  • In the prototypes of the function bhpeqns(), you declare a parameter float x[vars], where vars has not yet been declared, never mind defined. In a declaration such as this, the array size must be a compile-time constant; if you don't know the size of the array, use float x[] instead. This is repeated in the declarations of hooke() and bestsearch() as well.
  • You have #defined the value of nvar as 2, but then you delcare an int nvar; in the main() function. Since the preprocessor replacements take place before …
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Unbuffered I/O is operating system dependent; all of the standard C library functions operate on buffered streams. What OS are you running under?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I stand corrected. Thanks for pointing out that this can be done. I agree about Algol 68, though.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

There are quite a few problems with this program as it is written, but all of them can be fixed with some patience. The biggest issue I see is that you are reading in the name of the animal to be found, then overwriting that name repeatedly in the condition of the loop. You want something more like this:

            cout << "Please enter the name of the animal you are searching for: ";
            string petName;
            cin >> petName;

            while (inputFile >> name)
            {
                if (name == petName)
                {
                // get the file data here

Note the comment there, because that brings to light the second problem: you are reading the animal information only for the first animal, exactly once, and then printing out the data repeatedly. What you seem to want is to read the data only once the animal's name has been found, and then print out the results outside of the loop. This would make the code above look like:

            cout << "Please enter the name of the animal you are searching for: ";
            string petName;
            cin >> petName;

            while (inputFile >> name)
            {
                if (name == petName)
                {
                    inputFile >> visited;
                    inputFile >> cost;
                    average = cost / visited;
                    break;
                }
                else
                {
                    inputFile.ignore(1024, '\n');
                }
            }

            if (!inputFile)
            {
                cout << "Animal not found.";
            }
            else
            {
                //Display the animal name, times visited, and cost.
                cout << "The animal " << name << " was checked into the clinic " << …
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

First off, you need to recall that Java is case-sensitive. which means that PackageData and packageData are two different things. The former is the class name, the latter is an instance of the class declared in the main() method of PackageDataTest.

Second, the toString() method is something of an exceptional case in Java, as it is used implicitly whenever an object is coerced to a String value. So what is happening here is that the object packageData (not the class named PackageData) is being passed to printf() as its String representation, so packageData.toString() is automagically called.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Thank you pyTony , but i can't use Classes , i try to define a cliquable area in my close to my label.

If you don't mind me asking, why can't you use a class? Is it a case where you can't (i.e., you aren't familiar with developing them), or where you aren't permitted to? It seems like a strange requirement, which is why I am asking about it.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Perhaps it would make more sense to start with a parent class, Profession, which would have the various attributes in common to all the subclasses:

class Profession(object):
    def __init__(self, name, strength, pilot, intel, stamina):
        self.strength = strength
        self.pilot = pilot
        self.intel = intell
        slef.stamina = stamina

    # other methods common to all the subclasses would go here

class Starfighter(Profession):
    def __init__(self, name, strength = 20, pilot = 55, intel = 40, stamina = 35):  # defaults - can be overridden
        Profession.init__(self, name, strength, pilot, intel, stamina)

    # methods specific to Starfighters

class Diplomat(Profession):
    def __init__(self, name strength = 45, pilot = 20, intel = 50, stamina = 35):  # defaults - can be overridden
        Profession.init__(self, name, strength, pilot, intel, stamina)

    # methods specific to Diplomats

# etc. - classes for other professions here

You then could simply declare your characters as being of the given class:

defaultPilot = Starfighter("John Doe")
betterPilot = Starfighter("Luke Skywalker", pilot = 75)  # using custom values for the attributes

Hopefully, this will get you going. Let us know if you need more help on this.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I am certain someone can, if you you show us what you've already done on the problem. If you haven't started working on it yet yourself, then I would recommend familiarizing yourself with the details of the algorithm before proceeding.

We are here to help you learn. This is not the same thing as helping you get a passing grade, though heopefully we can help you do that as well. We will help fix problems with your code, but we won't provide code for you.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Wait a moment, how old is the textbook you are using? While Fortran is still in use - though in a form completely different from it's predecessors - Algol 60 and Algol 68 are long dead. Also, neither Algol 60 nor most older FORTRAN compilers have pointers, or structures for that matter, and thus cannot implement linked lists in the first place. WTF?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Both answers are accurate, but Banfa's answer is the correct one. Nutster's answer is true in the majority of implementations, but not all, and according to the standard the behavior is implementation dependent. You cannot count on any specific result without knowing the implementation in question.

As one famous quip on the subject went: 'undefined behavior' means that the program can, for example, cause demons to fly out of your nose if that happens to be the way it was implemented.

Note that this is not the same as random behavior; the implementation is generally still going to be deterministic, with a given implementation consistently giving the same results. You simply cannot anticipate the behavior from the standard. A consistent behavior on a given compiler, or even several compilers with similar implementations, does not change the fact that it is undefined by the standard.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Could you give us more information about what you need, and what you already know how to do? The problem description is rather sparse, at best. Do you have anything in particular in mind as far as what the program should do?

A few questions to get things going:
* Do you know how to write a function, and how to call one? Can you give a simple example of one?
* Do you understand what a pointer is, and what an array is, and what each is used for?
* Do you know how to declare each of them?
* Do you understand the differences between an array variable and a pointer to an array, when they can be interchanged and when they can't?
* Do you know how to combine each of these into a working function?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I should mention that the more conventional solution to this issue is to store a URL or some other sort of path to the image file, rather than the image itself. This avoids the whole issue entirely, as you then would simply access the image file normally. Would this be an option for you, or do you need to have the image data in the database itself?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Do you know if the DLL a C++/CLI DLL? If so, then calling it directly like this may not be possible. You may be able to use COM Interop to connect to it, but even that isn't entirely certain, if the DLL is 64-bit code.

BTW, why do you have to use it in VB6? Is this a legacy application or a new project? Is VB6 part of the project requirements?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Your senior consultant seems to be having a senior moment, I would say. This advice is not only wrong, it is dangerous, because VB6 and Oracle 9i are no longer supported by Microsoft and Oracle, respectively, and neither can even be run on an version of Windows more recent than XP without using virtualization. Microsoft has gone out of their way to make VB6 obsolete. Anyone starting a new commercial project in VB6 in 2013 is out of their mind.

That having been said, VB6 and Visual Basic.Net are completely different languages, with only superficial similarities and the same name tying them together. Moving from an existing VB6 code base to VB.Net is a major headache, which is the main reason the VB6 forum still exists.

Whether any version of VB deserves to exist... well, some people like it, anyway. If I only worked in languages I liked, I'd never get any jobs.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

As pritaeas said, we need to know more about what you're planning on doing. However, as a general piece of advice, I would recommend defining an abstract parent class - let's call it AbstractBullet for now - and deriving the different sub-classes of Bullet from that. If you do that, you can simply override the methods of the parent class, eliminating the need to explicitly test the bullet classes. For example, say you have a class FullMetalBullet and another ExplosiveBullet, then in your AbstractBullet class you might have an abstract method called fireAt(), which defines the trajectory of the bullet, and another strikeTarget(), which defines what happens to whatever it hits. The two sub-classes would then implement their own versions of the two methods, to define what the specific types of bullets do.

This is just some general advice on basic OOP principles; just what you'll want to do will depend on how you want it to behave. You might want to look up the [url=https://www.google.com/search?q=factory+pattern]Factory pattern[/url] as well, since you're going to be dealing with a lot of bullets of different types.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

First off, just to clear things up a bit: GCC itself does not have any settings called 'debug mode' or 'release mode'. These are purely a construct of the IDE, and how it works will vary from one IDE to another.

Basically, what choosing one mode or another says is, 'I want to use this set of options'. The IDE automagically passes the appropriate set of options to the compiler when it invokes the compiler. Most IDEs give you the option to set the specific options you want in each mode, but give a specific set of defaults that amount to what I told you earlier.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

First off, we don't do other people's homework for them. Second, we don't do other people's homework for them. And third, we don't do other people's homework for them. Sensing a pattern here yet?

No one here will simply hand you a solution on a silver platter. If you show us what you've done, what you've tried to do, and what problems you've had with it, then we'll be happy to help. If you have specific questions, we can answer them, or at least point you in the right direction. If you have a program with a bug you can't swat on your own, we'll be glad to assist, so long as you pay attention to the forum rules and post sensible questions in an intelligent manner that we have some reasonable hope of answering.

But just cutting and pasting an assignment into a message, without even prefacing it with something like, "I have this homework problem that I can't solve...", is likely to get you booted from the message boards here and elsewhere - if you're lucky. What happens to you if you are unlucky is... well... let's just say that this guy probably won't be trying that again, on that forum or this one.

We take this issue seriously here. Very seriously. Asking us to do homework for you is a grave breach of academic ethics on your part, and actually doing so would be an even bigger breach on ours (not …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I assume you are referring to and GCC-based IDE such as Code::Blocks or something similar here, correct? Basically, they are two different options for generating the executable, which some IDEs provide as a shortcut. They allow you to have two different sets of compiler options to be set up, one for use in development and the other for the final, optimized stand-alone version.

Debug mode by default simply means that it generates code with optimizations disabled (the -O0 option in GCC) and all debugging symbols included (the -g option). This makes it possible to debug the code with the GDB debugger, without having to deal with the various complexities of highly optimized code.

Conversely, Release mode by default has a high level of optimizations in place (-O2 or even -O3, though the latter option includes 'unstable' optimizations and is best avoided), and discards the debugging symbols. It is intended to produce a smaller, faster executable for distribution, at the expense of being able to debug it. Generally speaking, you would only switch to Release mode after you have finished testing and debugging the program, and are ready to ship it to users in binary form.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

For anyone unfamiliar with the game (as I am), the Wikipedia article on it is at least a starting point.

phats more: Can you be more specific about what you need help with? What have you tried so far? What do you know about C#, and what do you think you need to know? What other programming languages, if any, do you already know (so we can make comparisons between them)? Has the instructor given you any insight as to how to write the program?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

OK, and what was your question?

EDIT: The rest of this was incorrect; I had overlooked the fact that fgets() stops at newlines. Please disregard.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

First off, I would leave the course, as they are teaching you HTML techniques that are thirteen years out of date. No one uses tag properties for presentation anymore, and officially, they've been removed from the language (though most browsers will still recognize most of them).

Second off, no one here is going to simply provide you with the code. We are here to help you leanr, which is not necessarily the same as helping you get a passing grade in your homework. Show us what you already have done, and we will help you; otherwise, it would be Cheating with a capital C, something we do not facilitate at Daniweb.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

The former is straightfoward: on line 163, at the end of the game() function, you have the statement

 return EXIT_SUCCESS;

Now, since the game() function is declared as returning void - that is, no value - returning anything is an error. This should be simply

return;

or even just omitted entirely (void functions return implicitly).

The latter is also fiarly simple. On the line of the reported error, you have an extraneous left brace, before any functions. You can simply remove this brace to fix the problem.

Oh, I would recommend using whatever auto-indent program comes with your IDE, as it should highlight some of the problems you've been having.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

The endl manipulator is the standard way of sending a newline to a stream. You want to use it whenever you need to progress to another line on the console.

Chances are, it is because you didn't have a using namespace std; directive in a given function. It is better not to use that directive at all, but to explicitly scope the items imported from another namespace, like so:

std::cout << "Hello, World!" << std::endl;

This avoids any ambiguity in the scope. However, that's a lot of extra typing, hence the using directive. Normally, if you use the using directive at all, you would have it at the top level of the compilation unit, usually just after the #include statements, so that it applies to all the functions defined there; doing it on a per-function basis does give better control, but wastes a lot of typing, and can easily lead to the sort of problem you're having now. I would either use the explicit std:: scope for those items, or else just put using namespace std; at the beginning of the program.

As for being demi-gods, well, I'm pretty sure I'm not particularly divine myself, but I can't speak for the others here.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

As Moschops said, just what 'program analysis' means is going to up to the professor; there isn't really any standard meaning to it. In general, it means identifying the variables of the problem, describing the steps needed to solve the problem, and describing what user input or data is needed to solve it.

A flowchart is (or was - who the hell still uses flowcharts in the 21st century?) a standard method of describing the flow of control in a program by means of a diagram. It uses different kinds of symbols to depict actions, conditions, input and output points, and so forth. You will want to draw it out by hand, or find some program that automatically generates the flowchart symbols for you such as Flowchart.com or Lucid Chart.

As for pseudocode, the answer will depend on the specific 'syntax' which your professor wants. Basically, it is a text description of the program flow, similar to but less formal than the actual program code. For example, part of the pseudocode for your problem might look like this:

if the car's score is greater than 50, then
    accept the car
else
    reject the car

How detailed the pseudocode has to be will depend on the level of abstraction at which you are working.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Most of these issues come from incorrect nesting. If you look at main(), you will see that you have an extra left brace, just after the using namespace std;, and that you fail to close the function. This means that you are in effect declaring MenuSystem() as two layers of nesting in. This is masked, however, by the fact that you have semi-colons after MenuSystem() and game(), effectively making them compile as function prototypes.

Similarly, you do not close the functions MenuSystem() and ScoreHand(). Conversely, you skip the left brace at the beginning of game(), and close PrintCard() prematurely in the middle of the function.

Oh, and you don't #include <cstdlib>, which is where srand() is declared.

These are just the most obvious errors. There are some I will leave for you to figure out yourself. The good news is, once it is debugged, the game does work more or less correctly.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

What everyone is tap-dancing around is that, in order to get a consistent result, you need to synchronize the threads. This means that there would have to be an object which has a synchronized() block associated with it, which acts as a lock on that object - other threads cannot access that object until after the lock is released.

Here I have an example, derived from your code but now quite different, which demonstrates thread synchronization:

import java.util.ArrayList;
import java.util.concurrent.atomic.AtomicInteger;

public class SyncedHelloWorld {

    public static void main(String []args){
        ArrayList<Greeting> g = new ArrayList<Greeting>();

        g.add(new Greeting("Hello"));
        g.add(new Greeting(", "));
        g.add(new Greeting("World!"));
        g.add(new Greeting("\n"));

        Thread[] t = new Thread[Greeting.Count()];

        for (int i = 0; i < Greeting.Count(); i++) {
            t[i] = new Thread(g.get(i));
            t[i].start();
        }
        try {
            for (int i = 0; i < Greeting.Count(); i++) {
                t[i].join();
            }
        }
        catch (InterruptedException e) {
            // do nothing
        }

    }
} 

class Greeting implements Runnable {
    private final String phrase;
    private final int index;
    private static int count = 0;

    // The object position must be an AtomicInteger, as
    // it needs to be mutable. Ordinary Integer objects
    // generate new objects in auto-boxing, and the method 
    // would not have a lock on the new object.
    private static AtomicInteger position = new AtomicInteger(0);    

    public Greeting(String newPhrase) {
        phrase = newPhrase;
        index = count++;
    }

    public static int Count() {
    return count;
    }

    public void run() {
        synchronized(position) {
            for (int i = 0; i < count; i++) {
                // loop …
Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

When I think of the state of CS education around the world - and yes, especially in India - I am reminded strongly of what Dick Feynman said about Brazilian physics work in the 1950s: that there are a lot of people 'learning' computer programming by rote, without actually understanding the meaning of what they are doing. This isn't to say that there aren't brilliant Indian programmers - I've known several - but they are, for the most part, the one's who went out of their way to learn the subject, which means that despite the public efforts to educate people on the subject, the number of competent programmers is virtually unaffected.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Anyone who says that the current generation of programmers is in some way inferior to those of the past, is clearly unfamiliar with the programmers of the past. You must recall that until very recently the vast majority - 90% or more - of programmers were COBOL coders, often with only a few weeks of training before being set loose on the computer world. If you truly think that they were any more inclined to delve deep into the details of the field, you are deluded.

So why do the current coders seem so much worse? It's simple: numbers. The sheer number of newly minted programmers, and the considerable monetary gains to be made by working in this field, mean that the overwhelming majority of newcomers will be people with little actual interest in computing and are looking only for a quick paycheck. This last part has always been true, or at least has been since the early 1970s, but the sheer volume of would-be coders means that the education system in place is being swamped. This is especially true in places like India, Brazil and the former Iron Curtain countries, where the disparity in incomes is even more dramatic and where there have been strong pushes by the national governments to encourage people to enter the field, but little infrastructure added to facilitate them.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Oh? What would you need to change it for?

BTW, your operator>>() function may need work; while it will work correctly for a file, it will go into an infinite loop when reading from cin. I would recommend redesigning it to read one line of numbers at a time, and if necessary loop throough the input file explicitly. Also, it will fail silently if the input isn't numeric.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

My first suggestion is to look into the csv module in the standard library. It may save you from reinventing the wheel WRT comma-spearated value files.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Did you solve the problem? If not, what problems are you still having?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

While what mike_2000_17 said is all correct, the real reason is actually a lot simpler: C++ has no concept of console I/O because C++ - and many of the operating systems it operates under, including Unices - has no concept of a console. More importantly, C++'s standard libraries operates primarily on abstract streams rather than devices, and has no way of knowing if a given stream is a dumb terminal, a file, a network socket, or a window in a windowing environment. These are all system-dependent definitions. Not all systems have consoles, just as nt all systems have files, or network connections - again, consider the case of an embedded controller.

Moreover, the capabilities of a console vary from system to system, and not in trivial ways. You have to recall that the original Unix system worked primarily with TTYs, literal teletypes that printed output to a roll of paper. Even when more advanced consoles were available - which they were, even in 1967 - there was no standardization as to what operations they could perform. How do you handle the case of 'move the cursor to screen location (x, y)' when you don't know if the terminal in question is even capable of doing so, or even if it has a screen at all? While libraries like termcap and curses were eventually developed to work with different kinds of terminals in a uniform fashion, they couldn't be made part of the language because it would require thousands of different …

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Unfortunately, there is no standard way to read and display image files in C; it would depend on the operating system, the windowing manager, and the graphics library you are using. There exist several portable windowing libraries such as Qt, wxWindows, and GTK+, which include the ability to display image files as part of their operations; if you pick one of these, you should be able to display the images fairly easily. Otherwise, you would need to let us know what system you were targetting this for.

Also, what sort of image files do you need to display? There are several formats in widespread use, including GIF, JPEG, PNG, BMP, SVG, and TIFF. Do you need only one type of image file, or do you need to support several different ones?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

As Moschops said, Code::Blocks does in fact generate a stand-alone program whenever you compile a project. If you look in the project folder, you will find a folder marked Bin, with two sub-folders, called Debug and Release. By default, the compiled program goes into the Debug folder; this is a version of the compiled program with all of the symbol information needed by the debugger in it. If you go to the Build menu in Code::Blocks, and go to Select Target and check Release instead, it will put the compiled program (stripped of the debugging symbols, and thus smaller and possibly faster) in the Release folder.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

I take back what I said; there's a much easier solution, one which avoids all this problematic mucking about with the previous nodes: simply swap the values, rather than the nodes themselves.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Is there a specific requirement to use the bubblesort algorithm? With a linked list, an insertion sort would generally make more sense.

The main thing you'll want for bubblesort that you don't already have is some kind of swap() function. Since it is a singly-linked list, you'll want to pass it the nodes previous to the ones to be swapped.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

What error are you getting? I assume that dis is either an instance variable or a class variable, and thus would be in scope for both methods, is this correct?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

You would find it much easier to detect many bugs of this sort if you indent the code in a suitable fashion. While it may take some getting used to - it makes the code look like some sort of modernist poetry - it is well worth the trouble. There are even tools available to perform indentation for you, and these often do a better job than you would do by hand.

For example, here is your code as rendered in Allman Style using the AStyle tool:

#include<stdio.h>
#include<conio.h>

char oper[4];
int num[2],*a,*b;
int ans,i;

int main()
{
    clrscr();
    for(i=1; i<=5; i=i+1);
    a=&num[0];
    printf("Num:");
    scanf("%d",a);
    printf("");
    scanf(" %c",&oper[0]);
    {
        {
            if(oper[0]=='+')
            {
                b=&num[1];
                printf("Num:");
                scanf("%d",b);
                ans = *a + *b;
                printf("%d",ans);

            }
            else if(oper[0]=='-')
            {
                b=&num[1];
                printf("Num:");
                scanf("%d",b);
                ans = *a - *b;
                printf("%d",ans);
            }
            else if(oper[0]=='*')
            {
                b=&num[1];
                printf("Num:");
                scanf("%d",b);
                ans = *a * *b;
                printf("%d",ans);
            }
            else if(oper[0]=='/')
            {
                b=&num[1];
                printf("Num:");
                scanf("%d",b);
                ans = *a / *b;
                printf("%d",ans);
            }
            else
                printf("Error");

        }
    }
    getch();
    return 0;
}

Perhaps this will help you see where the problem lies with the for() loop. If not, consider what the semi-colon at the end of the loop conditional means.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

To give a perfectly serious and not at all snarky answer, the first question I have is: why Turbo C? Does the course you are taking require that particular compiler/IDE (I can't imagine any other reason for using such an antique, but I know that many schools in India and Pakistan among other places have standardized on it), and if so, how did you get to your 4th semester without using it before?

OK, maybe that was a little bit snarky. But to continue: what version of Windows are you running under? This is quite relevant, as versions of Windows from Vista on will not run Turbo C (or Turbo C++, for that matter) without using a virtual machine to emulate an older edition of the operating system. It will complicate the process of installing Turbo C, but it will still be possible (sort of).

Next, do you have an actual copy of Turbo C to install? It shouldn't take more than a simple Google search to find a downloadable copy, so I'll leave it to you to get it. The installation process should be self-evident.

Assuming that you have a suitable installation of Turbo C on hand, the solution is to... run Turbo C. That's really all you need do, as it will automatically create an editing window for you. Write your program and save it, then compile. Simple.

I have one final question, however: didn't your professor explain all of this to the class?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Let's start from, what do you know how to do already? Can you write something very simple, such as a program that prints a line of text (say, 'Hello, World!', to give one well-worn example)?

Getting to the assignment at hand, do you know how to write a for loop? Can you declare a simple variable? What about an array variable? Do you know how to write a simple procedure, and how to pass an argument to it?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

The immediate cause of the errors are a) the statement typeof(n) in the initialization section of the for loop, and b) the lack of a semi-colon at the end of f *= i. However, this ignores a more serious conceptual error (for which the compiler gives only a warning), in that it assumes that the for() loop will return a value, which is not the case.

What is really happening is that you are making one of the classic C/C++ conceptual errors, namely, confusing macros with functions. While parameterized macros do indeed seem to act like functions under certain circumstances, they are not functions, and treating them as if they were can come back to bite you.

In this case, if you look at the actual code generated by the pre-processor, the statement would become:

int j=for(typeof(i) i=2; i<=i; i++){f *= i};

A few moment's thought should make it clear why this won't work, even aside from the collision of the two i variables.

As an aside, you should never use void as the return value of main(); the correct return type for the main function is int.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Where is the error occurring? If you post the traceback - the entire traceback, please - it should show what line in the code the problem lies in.

Also, what is the search.Problem class? I wouldn't need details, just a general overview of the parent class so I can better unerstand the class you're developing.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

What is position, and where is it initialized?

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

It would still be possible to use the same basic loops to, say, gather the data into a pair of lists. Still, it all depends on just what you need to do with it, I suppose.

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

Assuming you don't need the data after printing it out, I would recommend shortening the code thusly:

            if andexfield == elem:
                print andexfield
                for p in range(1, 17, 2):
                    print p,
                print
                for q in range(2, 17, 2):
                    print q,
                print

The third argument of the range() function is an optional 'step' value, indicating how many values it should increment by each time; for example, range(0, 10, 2) would (in Python 2.x) give a list of [2, 4, 6, 8] as its result (in Python 3.x, range() is a generator; the values returned are the same, but it returns only one value per call, rather than a list).

Schol-R-LEA 1,446 Commie Mutant Traitor Featured Poster

When you say Eclipse 'fell apart', what actually happened? As JamesCherrill says, Eclipse is generally quite stable, so any catastrophic problem with it is quite unusual and deserves some analysis.