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

Is this a C or C++ program? You have a mixture of the two header files. It looks like mostly C so I'm moving it into the C board.

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

The problem seems to be nested includes. Each header files includes the other header file, so neither header is completly processed before the class is used in the other header. To avoid that problem predeclare the class. See the example below

Second: stdafx.h is not to be included in header files. This file must be included at the top of *.cpp files and must appears as the first include file. If you don't do this and you compile with precompiled headers then your program will not compile.

#ifndef __fibonaci__
#define __fibonaci__

#include "stdafx.h" // <<< this is not necessary in header files 

#include "Fibonaci_Iterator.h"

class Fibonaci_Iterator; // <<<<<<<<<<<<<<<<<< here

using namespace std;

class Fibonaci
// rest of header file here

Even if you make the above change you are going to have fatal problems because pre-declared classes can only appear as a pointer since the class has not been fully declared to the compiler. Looking over your code I think the easiest way to solve your problem is to remove line 4 from Fibonaci_Iterator.h

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

I thought I was able to duplicate the problem. I compiled the program on Vista Home Premium using VC++ 2008 Express then rebooted into XP with SP2 and the program will not run becaise pf the useless error message "Incorrect Configuration". I turned off debug, unicode and turned off embedding the manifest and it still doesn't run on XP. I honestly don't know what to do next to correct the problem except continuing researching the problem with google. I'll let you know if I find out something, or hopefully someone else will know the solution. Since its compiled on Vista maybe there isn't a solution, but that's hard to believe.

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

This thread seems to have a discussion of your problem. Scroll down to post dated Oct 31 2005 at 1:15 pm the poster seems to present a solution. You should probably read all the posts in that thread.

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

What version of the compiler are you using? Are the operating systems on the two computers the same? Can you post the code to your program ? What are the exact error messages you get from the operating system when you try to run the program (copy/paste them here) ?

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

that's better but still not correct. You need to put single quotes around the P and N, like this: return 'P'; Also see my comment #2 in my previous post -- you didn't remove that second parameter.

Next you probably need to add a main() function so that your program will compile and link correctly.

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

I don't know what happened but it seems to have resolved itself.

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

>>Does this look right?
Close, but its not right

1) line 1: the function is supposed to return a char, not double. So you need to declare it as char Letter ( double P) 2) The function is only supposed to have one argument, not two.

3) You forgot the open and close braces around the body of the function.

4) line 3: remove the semicolon at the end of that line.

5) The return values on lines 5 and 9 are wrong. You are supposed to return the letter P is the parameter is a positive value. That means you have to compare the value of the parameter to 0. If greater than or equal to 0 then return 'P' otherwise return 'N'.

6) Delete line 11 because I have no idea what that is supposed to do.

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

I'll bet my boots that you compiled the program for DEBUG. Change the setting to use RELEASE and it will probably work ok. How to change from debug to release depends on the version of the compiler you are using. If you already compiled for release then there couild be a thousand reasons why it won't run, including a lack of the correct DLLs.

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

Weocome to DaniWeb Rocky. Hope to see you around a lot.

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

Well the whole problem is that it is taking 35-40 seconds to load the information on the right side of the screen as well as the rest of the posts in the thread. Strange that no other web site I visit has this problem, only DaniWeb.

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

The problem seems to be with Page --> zoom. I normally have it set on 100%. But starting this afternoon I can't see more than the first page of any thread on DaniWeb. If I change it to 200% and back again to 100% it gets corrected and now I can see all of it. I have to do that with every thread and occasionally that doesn't work either.

In the attached thumnail please notice that the entire right side of the screen is not loaded either.

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

Are you having database problems? All I can see of any thread is the first post -- nothing beyond that even in threads that have double-digit posts. Its not confined to just one thread but all threads on all boards.

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

You have to have been a smoker in order to understand my statement. And got God's sake don't start smoking just so you can find out what I meant :ooh: While I smoked running was a real difficult task and I was not able to sustain it for very long because of becomming winded and painful lungs. Now, my endurance has improved dramatically and can continue working out for at least an hour without stopping for very long. That wasn't possible when smoking.

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

You are right Dave -- I wrote a program at work once that used filenames with dates in MMDDYYYY format and lived to regret it because the program generated a new file every day. The next time I revised that program that was the first thing I changed.

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

how do you expect to get a value like 0.07 with integers ?

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

>>The program's suppose to generate 50 random numbers
It isn't -- its generating 255 random numbers.

line 63: That is doing integer arithmethic because both the numberator and denominator are integers. If you want decimal places in the result of the division then you have to convert them to floats or doubles by either typecasting them or declaring x and y as floats. initialArray[i][j+2] = (float)x / (float)y;

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

do you guys prefer whisky or irish whiskey?

I don't like whisky or burbons. Vodka, Gin, Kalua, Irish Mist are about the only alcholoic drinks I used to drink -- don't do that anymore either. I was never alcholic just stopped drinking due to other medical problems. **sighh**

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

Ugh, one of my half retarded days. lol

Thanks.

We all have those kind of days on occasion. :)

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

I already posted the code that checks the filename to see if it exists or not. If the filename does not exist then that loop will exit and the filename is ready to use in the output file. I see that I forgot to increment the counter, so I just now added that to my post above.

How are you formatting the date part of the filename ? Do you already know how to do that ?

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

Depending on the file format you would normally read the data one element at a time. The example file you posted in your original post -- does the file really contain those commas ? If not then it would look like this when viewed by notepad

7 15 30
5.35 5.50 5.75

If the above is correct, then

int iarray[3] = {0};
float farray[3] = {0.0F};

ifstream in("filename");
in >> iarray[0] >> iarray[1] >> iarray[2];
// do the same with the float array

Or you could use loops in the above. Either will work for your program.

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

does your program ever call munmap() to release the memory back to the os? If not then maybe your program is just simply running out of memory.

Also about ftruncate() -- maybe you already know this.

If it <the file length> was previously shorter than length, it is unspecified whether the file is changed or its size increased

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

line 46 writes the same array to the same file 12 times. And the use of the asterisk on that line for *ArraySize is also illegal because ArraySize is not a pointer. Even removing the asterisk its still wrong because you don't want sizeof(ArraySize) because you already know the array size. What you want is ArraySize * sizeof(double) . BTY you did it correctly on the very next line.

The filename is incorrect because it doesn't do anything with the date or increment the number. You have to format the file name to accomplish that.

After getting the number you want to use in the filename you have to find out if a file already exists with that name. The easiest way to do that is to try to open the file for reading. If it does not exist then the open file fail and when that happens increment the number, reformat the filename, and do try it again.

Here's a simple way to format the file name

#include <string>
#include <sstream>
<other includes here>

...
string filename;
int fileno = 1;
string date = "19-FEB-09";
do {
    stringstream str;
    // format the filename here
    str << date << "-" << fileno << ".dat";
    filename = str.str();
    ++fileno; // increment for next loop iteration
    // attempt to open for read
    ifstream in( filename.c_str() );
} while( !in.is_open() );
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First DJ you should know that MS-Windows programming is not really for beginning programmers -- you should (must) have a good working knowledge of the entire C language, well most of it anyway. c++ is not required. No MS-Windows tutorial will teach you that. The tutorial that John posted is probably one of the best on the net and used by almost everyone that I know of. But it, like other tutorials, only give you a bare intorduction. If you want to be a searious MS-Windows programmer then you need to invest some $$$ in books, which you can find at your local book store or online at www.amazon.com. See the Read Me links at the top of this c++ board for additional book recommendations.

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

It doesn't matter which one you use as long as you understand the not operator. I prefer the "== 0" form myself because it doesn't require so much thinking to know what is going on. But, unless told otherwise by your teacher, either one should be acceptable.

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

The best water I ever drank in my life was tap water in New York state somewhere near the great lakes (I don't recall where but probably close to Buffalo). I stopped in a resturant and had a glass of water with other things. It tasted sooo good that I stayed an hour or so just drinking the water because I couldn't get enough of it. I have never tasted even bottled water that was as good as that tap water in NY.

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

You should listen to your teacher first. A simple yes or no does nothing to help you understand the problem. From what you posted you should first use strcmp() to see if the last names are the same. If they are the same, then use strcmp() to see if the first names are the same. If they are also the same then check the id.

One way to do it is somthing like you posted, that is to call strcmp() for all three cases saving the results in different int variables, then check those variables for equality. That, however, is the long way around the problem because if, for example, the last names are different then it was not necessary to compare the first names or id's. A more efficient solution is to only call strcmp() when absolutely necessary to do so.

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

alright, not snotty but rude by the last comment of "And I WILL NOT DO YOUR HOMEWORK!"

Oh now I know what you mean. Look at all my posts -- that comment is in my signature and appears in every post I make. It is not directed to you, but to all newcomers. I have that in my signature because there are many many people who do actually ask us to do their homework for them. I'm happy to see that you are NOT among them :)

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

Did I ask for you to do my homework? No. I asked if I was in the correct direction, a simple yes or no would suffice,

No you didn't ask me to do your homework. And No I didn't realize that was all there was to your assignment. I apologize for helping you. I deleted all the code in my post so that you can have the joy of doing it yourself, unless of course you have already copied my code.

So, the answer to your questions I asked if I was in the correct direction is NO.

not a snotty remark.

What ??? I didn't say anything in my post -- just posted some code. I try not to make "snotty remarks" to anyone, so I'm sure you over-reacted or have me confused with someone else.

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

<code deleted>

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

Right now I'm into diet Sunkist Orange soda, diet A&W Rootbeer, diet A&W Cream Soda, and diet Coke. Also love unsweetened ice tea.

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

Well its pretty simple then, read the first three numbers into the first int array and the last three numbers into the float array. Beyond that hint you will have to post your code to get further assistance.

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

You need two arrays, the first is an array of integers that has the load terms and the second is an array of floats with the load amounts. There are other ways to do it but I doubt you have learned structores and c++ <vector> yet.

Exactly how to read the file depends on the exact instructions your teacher gave you. For example can you assume there will only be three loads in the file or do you have to consider a variable number of loans ?

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

my code on the line of error

const char * "c:\\My Programs\\myfile.txt" = argv[1];

That line is malformed. Should be either

const char * pFileToDelete = "c:\\My Programs\\myfile.txt";

or
const char * pFileToDelete = argv[1];

Use argv[1] line if you want to type tye filename on the command line when you execute your program. Otherwise if you just want to hard-code the filename into your program use the first version.

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

How would I declare the delete file function,

just #include <windows.h> If you don't have that installed on your computer then you can't use that function. Use the standard C function remove() instead.

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

Hi happygeek,
I saw the address I put as a reference was <snipped>.
I read the rules and I saw it might appear as spamming.
I didn't mean to do that, the link was to let a deepening of my work's contents.
Should I write the address, without hyperlink?
Shoud I just say "click on my name to see my blog on green IT"?
Is there any best practice I should follow?
Again, sorry for unintentional spamming.
S

Welcome to DaniWeb. You can put that link in your signature and it will be displayed on every post you make here. Just click Control Pannel at the top of the page and you will see how to change your signature.

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

I really hope you're right, because I'm going to quit in a few months after 8 years of smoking. Smoking will be banned from the bars/disco's/restaurants etc in July here in the Netherlands. So I thought that this would be an excellent excuse to quit smoking.

Yes it will help you a lot. I used to chain smoke at my desk in my office until they banned smoking from office buildings. After that I had to sneek outside in all kings of weather to get a few puffs.

After a couple weeks or so without tobacco you will begin to see a huge difference in your life and you will be able to do things you couldn't do in many years, like working out at the gym or health club with relative ease.

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

I think it's too late for smokers to avoid smoking :)

Naw -- if I can do it after 42 years of heavy smoking then anyone can do it too. It just takes a lot of willpower and support from family/friends.

[edit]Ohhh. After rereading I think I understand you comment. Agreed -- its a contridiction to say that smokers can avoid smoking. You can't avoid something you already do :) [/edit]

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

No. It means that foo() can not change any class values

class A
{
public:
    A() {m_x = 0;}
    int GetX() {return m_x;}
    int foo(A& obj) const;
protected:
    int m_x;
};

int A::foo(A& obj) const
{
    m_x = 2; // <<<<<< THIS IS ILLEGAL
    return obj.GetX();
}

int main()
{
    A obj;
    obj.foo(obj);

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

Here are some good books from amazon you might want to get.

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

I want to make simple C Program which show current directories and files like dir or ls .This should be use interrupt for getting current directory and its subdirectories and files.Help me to make this program. I Saw 21h interrupt with its service 47h and 4Eh .

Thanks

You completly sidestepped the question about what platform you are using and what you intend to do with it, such as interface with java. With your level of programming knowledge surely you can write your own assembly program that will do what you want.

If all you want to do is give us a lecture about why our suggestions are of no value to you then sorry, but we won't be of much help to you.

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

Just tested it -- 1:15 minutes from the time I pressed the power-on button until the login screen appears. About another minute until the desktop is usable. But the time for that part would vary greatly from one computer to another due to what all is installed that has to be auto loaded.Mine has antivirus, Folding@Home, three gadgets, winzip. and of course the network connections.

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

Ah, yes.
And of course the 12th Amendment.

But are Bill and Hillary that close that they both live in the same state?

Good point :)

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

It looks like it should work. Use your compiler's debugger and set a break point on that return statement then when the program gets to that point you can inspect the value of all the variables. If you don't know how to do that then just put some cout statements to display the variable values.

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

Make sure you have permissions to delete the file and that the file is not marked for read-only.

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

Use two different file pointers

ifstream in("filename"); // input file 
ofstream out("anotherfilename"); // output file
start of loop
    read a line
    check the string to see if it contains the search word
    if yes then write the new line to output file
    if no then just write the line to output file
end of loop

>>i dont know how to wipe a file, or indeed delete anything from a file.
See this code snippet. DaniWeb has a lot of C and C++ code snippets that I'll be you have not eveen seen.

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

Great discovery there AD! That means only one thing, Bill wants to be her running mate if she wins. Wonder if that would be legal?

Bill could not be her running mate because he is not eligible to be President. He still would be ineligible even if he were not a former President because the Pres and VB can not be from the same state (or so I've heard).

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

If you know where that file is then just give it the full path
DeleteFile("C:\Program Files\filedel.txt");

There is no such function as FileDelete()