Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Huh ??? You can have mine for a million dollars :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My guess is that your program is crashing sooooo bad that the destructor is not getting called, the program is just dumping back to the os without doing any cleanup. You really need to find out what is causing the exception and fix it. Lacking that you should implement exceptions (try/catch blocks) as ithelp suggested.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

your formatting is horrible. Lign up the code so that we all (including you) can read it. Proper indention goes a long way towards understanding.

If you really wrote all that code then I think you are well on your way to completing the assignment yourself. Do the assignment one requirement at a time and start the second requirement only after the first is code, compiled without error and working.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

copy it one letter at a time, like this and also the loop needs to stop when end-of-string null terminator is found in the letter array.

char letter[8]="abcdefg";
char temp[10][2] = {0};

for(int i=0; letter[i] != 0;i++)
   temp[i] = letter[i];
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you want to delete those lines from the file itself then you have to rewrite it. First open that file for reading, then open another temporary file for writing (name it anything you want except don't give it the same name as the original). After that, code a loop using getline() to read a line from the original file and if it is not one of the lines you want to delete write it back to the temp file. After the file has been completely read close both file, then delete the original file and rename the temp to the original.

After you get the above working then you can do the rest of the assignment.

A word of caution -- until you have the above all coded and working right you should make a duplicate copy of the original file so that you can easily restore it if your program screws up, which it most likely will do.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>And whats the difference in malloc and calloc?
calloc() calls malloc() then initializes the data to all 0s.

The code you posted is allocating an array of n floats

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

We are not going to do you homework for you -- here are links to bubble sort code that you can use.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

google for sorting algorithms and you will find the algorithm you are looking for. Not sure what you mean by that last statement Get a program working with the bubble sort all coded in one file, after that works then you can split out the bubble sort into a different source file and create the header file.

>>sorting display must be have 7 screen which the sorting is sort in step and show in step.
not sure what you mean by that -- can you post an example

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Do you have a textbook ? Have you read it ? If not, why not. Read the Read Me threads at the top of this board and you will find lots of information that may help you.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

post what you have done so far. you should probably be able to write the skeleton for the find_a function.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

the same error shows at *

count braces -- functions can not be nested.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What about in C. É

what is that language? Do you mean C# (maybe your keyboard doesn't have a '#' symbol?)

>> because array sizes must be compile-time constants
Not any more -- C99 has changed that for C language, not sure if it will also apply to C++ or not.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Notice how float *a and float a[] are exactly the same thing
You are right in the code you posted, but the two do have a couple differences. a[] can not use pointer arithmetic like you do with *a so they are not interchangeable.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

your examples are kind of screwy but I think I know what you want. There are two ways it could be done -- either as an array or a pointer to the data. The difference between the two is how you want to access the data in func2() -- use the index notation such as container[0] or pointer notation, such as *container . And just to confuse you a little more the second method can also be referenced just like the first.

// prototype the function
void func2(float container[]);

void func1()
{
     float container[]={0.1,0.2,0.3,0.4};
     func2( container );
}

void func2( float container[] )
{

}
// prototype the function
void func2(float* container);

void func1()
{
     float container[]={0.1,0.2,0.3,0.4};
     func2( container );
}

void func2( float* container )
{

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

VC++ uses nmake.exe which is very similar to make.exe.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Don't ever try to ask them for help, because ,that program is all I want to, but they don't ever help me, instead, they got angry to you!!!
brightstar!!!

And where did you ask anyone for help other than "give me your program because I'm too lazy to do it myself" kind of post ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>This goes the same for a "For Loop"?
Yes, both these have the same identical result.

int i;
for(i = 0; i < 10; i++)
and 
for(i = 0; i < 10; ++i)

These two, however, are different

int i;
for(i = 0; i++ < 10;)
and 
for(i = 0; ++i < 10;)
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>otherwise if they had been pre increment would the value of the expression 'a1+b+c' be any different
No they are the same. pre and post increment only has any real difference if used in an expression of some sort. For example

int a = 1;

foo(++a);
foo(a++);

In the code above the value of a inside function foo() will be different because in the first instance the value of a is first incrmeneted then that value is passed to foo(). In the second instance the current value of a is passed to foo() then incremented after foo() returns to its caller.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Can I then use this to easily parse ...
easily is a relative term and depends on your experience.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>can tell the compiler to compile C code rather than C++ code.
Yes, just name the source file with *.c extension instead of *.cpp and the IDE will know how to compile it.

>>I am definitely going to buy the ANSI-C version of the K&R book
Get a different book because even that one is out-of-date. See the Read Me threads at the top of this and the c++ boards for good suggestions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No problem -- just call atof()

float n = atof(tmatrix[i]);

Not a perfrect solution, but works ok for most purposes.

iamthwee commented: Nope -3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Is there a way to output a whole struct to a text file in one go, instead of variable by variable which is all i can do at the moment?
In a text file that's the only way to do it. You can put all the variable for one structure on one line, with spaces or some other separator between each variable, and a '\n' at the end of the line, or you can put each veriable on its own line. Which way to do it is probably up to you (assuming your instructions do not state otherwise)

>>Likewise can I pull the information back out of the text file in structure form or does it have to be done character by character?
Not necessary to do character-by-character. Exactly how to do it depends on (1) how the file is written and (2) the structure itself. You didn't post the structure so I can't say further. But if there are no embedded spaces in the variable strings then you could use ifstream's the >> operator to read the entire variable value.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>the problem is when i run (F9),
That doesn't mean a thing to anyone here because you didn't say what compiler you are using. The F9 key could do anything including display some porn film :)

Next problem is that the code you posted won't compile without errors. Clean it up before attempting to run it (I guess that's what F9 is supposed to do). Notice that getWages is coded inside main(), which is always illegal to do.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well I'm pretty certain your problem is the way you have your environment set up because I downloaded and installed the SDL lib source, sompiled it, then ran one of the tutorials I found here. I used VC++ 2005 Express compiler with the Windows SDK and DirectX SDK installed.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

google will give you a lot of help, such as this one.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>could any1 suggest a free c++ compiler, that works fine on vista.
VC++ 2005 Express and Dev-C++ are just two of them. Borland ++ probably also works but I have not tried it.

As for your problem what compiler(s) have you tried. If its pretty current (not ancient Turbo C) then I doubt the problem is your compiler but the way you have it set up. Post a link to where you got that library and post your program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>"linker error undefined reference to mciSendStringA@16"
That is a completly different problem. It means it can not find the code to that function which is probably in a library somewhere. You need to find out what library that function is in and then add it to your project.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I agree with Salem -- buy a new book. You wouldn't teach your son or daughter to drive with horse & buggy so why learn to program with that ancient and long-out-of-date book.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>The following changes the subsystem type for Win32 exes
And why in the world would he want to do all that? It isn't necessary just to hide the command window when a console program starts. As Salem mentioned, he can't do it with the compiler he is using and needs to get into the 21st century compiler.

Once you have a compiler that can access win32 api (32-bit compiler) its pretty easy to remove the command window. Your program will need to link with user32.lib, which is supplied with the free-to-download Windows SDK (Software Development Kit)

#include "windows.h"

...
int main()
{
    HWND hWnd = GetConsoleWindow();
    ShowWindow(hWnd, SW_HIDE);

    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If your debt grows quicker than the min repayment can reduce it, then it will grow and grow until it reaches infinity (which is what #INF means).

Yes, just like people's credit cards :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I'm not doing your debugging for you. Look at the error messages and the line numbers and see if you can't see the problem. The first one is on line 42. Why ? I'll let you figure it out yourself. With 359 posts you should be able to do that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It would help if you get a clean compile. There are several syntax errors in the code you posted. Impossible to help you until they are corrected.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1. That function is doomed to fail because line 23 declared a 3d array of pointers. If what yoiu really want is a 2d character array where each element has room for 20 characters then you need to drop the star and just declare it like this: char wds[20][20]; 2. The two loops in your bubble sort are coded wrong. Should be this:

for (pass=0;pass<5;++pass)
{
     for(i = pass+1; i < 6; ++i)
     {
        // code here
     }
}

3. you have to use strcmp() to compare the two strings. Your program at line 43 is mearly comparing two pointers, not what they are pointing to.

if( strcmp(wds[pass], wds[i]) > 0)
{
   // swap the strings
}

4. You can not swap the two strings like you are attempting to do on line 45 You have to use strcpy().

5. why do you have the second parameter to dsort() ? It is never used so you might as well delete it.

6. Moved this thread to the C board since its a C program, not c++

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My guess is the problem is in stack2.cpp. But since you did not post it there is no way to tell. Also please post the exact error message including file and line number

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I would apprecate any and all help on this program that is due tomorrow
I doubt you will make that deadline and we will not write the program for you. If you have had a lot of personal problems that prevented you from studying, then you should probably drop this course and retake it next semester.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

moved

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

apparently requirement 4 wants you to make Celsius the integer result of the calculation -- typecasging the math result to int, like this?

int C;
C = (int) ((F - 32) * 5.0 / 9.0);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First, make sure the destination string is NOT a string literal, and that the size of the destingation string buffer is large enough to hold both strings. Once you know that, then find the end of the destination string and copy the source string at that spot one character at a time and in a loop. You can use pointers to do that or some indexing scheme you devise.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

depends on how you want to use it. If you want to pass a pointer to a double as a parameter to some function that takes char* then typecasting might work, depending on what that function is going to do with it. Normally, however, you will have to convert it storing the results in either a character array or a std::string object.

Two ways come to mind: sprintf() will convert and store in a character array, while std::stringstream will convert and store in std::string object.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The loop should keep a running total of the numbers entered

It does that

and stop when total is greater than 300

Look at the end of the do-while loop -- it is testing the wrong variable. Variable num just simply counts the number of entries made, so you would have to enter over 300 numbers before that loop stops. :-O The condition should be based on total, which is the sum of all previously numbers entered.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

probably because you need to add a line between lines 15 and 16 that removed the '\n' (the Enter key) from the keyboard buffer. The easiest way to do that is to use ignore() method

cin.ignore();

There are cases where the above won't fix the problem, but if all you type after the digits is the Enter key then the above will work.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Write a program segment with a do-while loop

your program does not do that. You used a while loop, not a do-while loop. Otherwise the rest of your program looks ok.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

pretty simple actually -- replace cout with an ofstream object. You have already included all the necessary header files so all you have to do is declare an ofstream object at the beginning of the program and use it instead of cout wherever you need to.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Please help the new programmer

Well, if you are really new then you need to start at the beginning, not with some really difficult program. Read the Read Me threads at the top of this board and you will get lots of help and places to look.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>would i do
Not quite. you have to use valid assembly language syntax.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Let me get this straight -- a nutcase enters a police station and seriously wounds two cops. People start burning cars because the cops shot and killed the guy ???? Are you certain those events didn't happen in Washington D.C. USA ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

like this ?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

are you doing this on your own or are you reading some tutorial? Read chaper 5 of this tutorial for help on how to include resource files in a project.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Look at lines 128 and 130 and see if you can't figure out why the averages are zero.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

haven't you learned anything yet? you have to declare variables before you can use them!