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

A couple years ago I walked into a doctors office and the receiptionist told me that she had to do evething manually because her computer was broke and a repairman had not yet arrived to fix it. I asked her what happened to her computer and she told me she tried to print something and the computer just hung up -- she could not use it at all after that. I looked over at the printer and did not see any lights on it so I asked her to press the On button. She did, and guess what -- the printer warmed up and printed whatever it was that she tried to print early that morning. All that time wasted because she failed to turn on the printer when she turned on her computer that morning :)

In another case, some 15 years ago now, I was working nearby St Louis and a client in Seattle had a problem with a program I had written -- it just wouldn't work. So my boss asked me to fly up there (a 4-hour flight one way) and find out what was going on. I did, walked into his work place, pressed the computer's On button, and everything worked just fine after that. The client, of course, paid for my time as well as tavel pay (air fare both directions). Cost him maybe $1,000.00 or more for me to fly up there and turn his computer on.

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

The project you are compiling contains at least two main() functions, one in test.cpp and the other in test2.cpp. You need to delete one of the two main() functions, or one of the two *.cpp files.

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

infp is a pointer to a FILE structure, which is returned by fopen(). The statement is actaually written incorrectly. More accurately it should be while( fgets(buf,MAXLINE,infp) != NULL) fputs(buf,outfp); There is not need for feof() because fgets() returns NULL when end-of-file is reached.

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

pixelmap::pixels is NOT a multi-dimensional array -- it's a single dimentional array. You have to add one star for each dimension. For example, for a 2 dimension array you declare it as pixel** pixels; Then allocate it like this:

this>pixels = new pixels*[height];
for(int i = 0; i < height; i++)
   this->pixels[i] = new pixels[width];
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I used Access in an environment that had about 60 users and had to replace it with Sybase Server (this was in late 1990s). I'm not sure how you used Access as a front-end to another database, but that's ok because I'm not really interested.

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

What compiler are you using? VC++ 2010 does not allow you to declare variables like you did on line 58 because iFS must be a constant. The new c++ standards will probably allow it, but for now it's not permitted except as a compiler extension to the current standards. That error is most likely what's causing the problems you described.

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

Post the entire program so that we can compile it.

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

yes -- add another thread and put the code for your clock in that thread.

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

There is no such thing as a pure OOP c++ program. There are only two kinds of programs: event driven and procedural. MS-Windows GUI is event driven where someone clicks a button and the program responds to it. Console programs are procedural where they just run from start to finish, with a few loops and threads tossed in between the two ends. Both types can contain a few OOP concepts, such as classes, but that is about the extent to which c++ supports OOP.

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

Yes, you can create the program, but VC++ can not compile for platforms other than MS-Windows and a few embedded devices. IMO if you need the program to be compatible on both MS_Windows and *nix then use Code::Blocks with MinGW on MS-Windows and Code::Blocks with g++ on *nix. If you want to write a GUI program then use QT for cross-paltform.

Kieran Y5 commented: Making me happy ;) +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you probably didn't include <fstream> and add using std::ofstream;

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

lines 18-31 -- why do all that memory allocations?? Just declare the variables normally and pass them to other functions by address, something like this.

static unsigned char buffer1[101];

/**********************************************************************/

int main()
{
    static cwbDQ_QueueHandle queueHandle;
    static cwbDQ_Data queueData;
    int result = 0;
    static cwbCO_SysHandle sysHandle;

    result = cwbCO_CreateSystem(TEXT("172.22.1.200"),&sysHandle);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I would agree that as a single-user or maybe even two-user database Access is probably just as good as any other. The problem with Access comes in with multiple-user. When there are three or more simultaneous connections Access becomes very very slow and frequently corrupts the database files.

>>The market is not an academic institution

True -- but it something won't work in academic environment it won't work in business either.

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

Maybe the easiest way to do that is to make a completly new linked list. Transverse the original linked list and select the nodes that have 25% discount then add them to the new linked list. After that add all the other nodes.

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

Look at the methods of the Book class and see if you don't find a way to do that.

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

>>book=new Book(T,P);

The error is telling you that the Book class does not have a constructor that takr two arguments. You need to add another constructor that takes two strings.

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

Don't use Dev-C++ -- its and ancient and unsupported compiler/IDE. Much better if you get Code::Blocks which uses current version of MinGW compiler. Here is a tutorial

Fbody commented: Agreed. +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

It's very similar in c++

#include <iostream>

int main()
{
  std::cout << "2.345 + 1.23 =" << 2.345+1.23 << '\n';
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I want to download it from work. But obviously there's a firewall stoping me from going into 99% of such sites

You don't like your job very well do you??? Attempting to get past the firewall will most likely get you fired. Download that music from home where you can do with it what you want.

All the sites I've visted require you to pay $0.99 per song -- and describing how to download pirated stuff is forbidden here and could get you banned.

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

Questions about DaniWeb go in DaniWeb Communicty Feedback

Agapelove68 commented: Thank you for being helpful. I appreciate the tip, where to post my questions with, "How do you...?" oops you misselled community, but I navigate there. :) +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>I am not really quite following you about posting the code between code tags. Can you please tell me exactly what I need to do?

[code] // <<< this is called a code tag // put all your code here

[/code] // <<< this terminates the code tags

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

read this thread and its example program.

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

first create a structure to hold all the information from one student.

Next you will have to know how to open a file and read it, most likely one line at a time. If you don't know how to open a file and read it then you need to study your textbook about FILE, fopen(), and fgets().

Finally you will need to know how to create a linked list of those structures I mentioned above. Again, your text book will show you how to create a linked list.

After you have started writing your code, you can come back here, post the code you have written, and ask specific questions about what you don't understand.

vinitmittal2008 commented: Fully Agreed.. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Did you see this thread? When you installed your 64-bit compiler it should have also installed by *.lib file. You should not have to download it from anywhere. Search your file system and see if you can find it.

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

>>Function read will periodic read dat from file to buffer
By periodic, do you mean once an minute, hour, day, week, month, or what?

I think you might want to have your program create two threads -- one thread for reading and the other thread for writing. Then the program will have to synchronize access the the comment buffer you mentioned -- look into semaphores.

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

>>void main ()

main() always returns an integer -- its never void even if your compiler allows it. Many compilers won't let you declare void main(). Get into the habbit of writing programs correctly and always declare it as int main() or int main(int argc, char* argv[]) I could offer some other suggestions to fix your code but won't because you failed to post the code between code tags.

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

There are lots of problems in function main(). Since I am responding to your post after 6 hours from when you posted it I hope you did not sit idle all this time watching TV, playing games, or anything else.

I could go on and on about all the problems I see in main() but it would be useless if you have already fixed most, if not all, of them. So please re-post your current program so we can see what progress you have made.

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

So, you upgraded from Office 2003 to Office 2007, and not Outlook 2007 doesn't work? Before resorting to restoring the entire system try re-installing Office 2007 and let it fix any errors that it might find. Make sure you are logged in an Administrator account when you do that.

What version of MS-Windows are you running?

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

You are supposed to put the *.lib there, not the *.dll. When you created the DLL the compiler generated both the *.dll and *.lib files. The *.lib is the file your project has to link with, just like it does with all other system libs and DLLs.

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

for (int i=0;i!=sizeof(nstring);i++){
if (nstring== ' \\ ' )
nstring<< nstring+ "\\";
}

what is it wrong?

sizeof(nstring) is not the same as strlen(nstring). Since nstring is a pointer, sizeof(nstring) is the same as sizeof(any pointer here) which is always the same value -- size of a pointer. For 32-bit compilers that will be 4. Don't confuse the difference of sizeof() operator and strlen() function because they are not interchangable.

>>char* nstring="C:\Program Files\C++\myfile.txt";

When working with string literals you have to use two \\ characters, like this: char* nstring="C:\\Program Files\\C++\\myfile.txt"; The two \\ are needed when the text is enclosed in quotes, like that statement.

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

google for that library and you will find several threads that discuss the problem.

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

what is %2 supposed to mean? Or do you just want to print %2 on the console screen? If yes, then just use int 21 instructions to do that, assuming you are using Intel or compatible processor.

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

You don't understand the use of the double \\ in strings. The \ chacter in C/C++ is used as an escape sequence and tells the compiler to treat the following character differently from other characters. For example '\n' is a newline, '\t' is a tab (there are several others), and '\\' tells the compiler to treat \ as a character literal instead of as an escape characters.

That is all unnecessary when you have a character array that already contains \ charcters in a path. OpenFileDialog() will return a string that already contains \ folder seperator characters so it is not necessary to replace each \ with \\.

>> but with simple \ between the root folders C++ doesn`t let me do that
There has to be something else you have done wrong because single \ works for everyone else in the world. My guess is that when you add the file name to the path you didn't put a \ before the file name.

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

Did you recompile the DLL with that 64-bit compiler and add the *.lib to the project you made (you did make one didn't you???) for idefile.cpp

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

>>Anyways, if it outputs correctly in the console, shouldn't there be a way to make that output into a new text file instead of the console?


Your program is trying to read the data in one function and write it back out to another file in another function. The only way that can be done like that is to save all the data in memory when it is read.

The alternative way to do it is to write it back out to a file in the same loop that reads it. If you do that then neither outputData() nor the vector is not needed.

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

I've seen that several years ago -- browse around Tools --> Options.

[edit]^^^ Oh yes, there it is :)

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

The loop on line 55 is not saving the data in memory. It is just simply overwiring all the data that was read during the previous iteration of that loop with new data. If you want to do anything useful with any of that data you need to save it into a vector of structures, where a structure contains all the data for one line of the file. Once you have that finished you can easily store the contents of the vector to a file in another function.

structure customer
{
   string name;
   string address;
   string city;
   string state;
   string zip;
};

vecotor<customer> custdata;


... <snip>
   customer cust;
   // note that eof() is not needed here.
   while(getline(inData, cust.name, '^'))
    {          
       getline(inData, cust.address, '^');
       getline(inData, cust.city, '^');
       getline(inData, cust.state, '^');
       getline(inData, cust.zip);
       custdata.push_back(cust);
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First you need to add the code that reads the firs line of the time. The code you posted doesn't do that. Put that code on line 18.

Next, starting on line 41 add code to read the data for each of the three matrices.
Here is a thread that might help you with that code.

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

You most likely have to include <string> header file

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

line 46 does not require use of new because bar is not a pointer. This is all that line 46 needs to do. bar b(fc);

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

Ignore the vector part and concentrate on how it recognizes a new sub directory and makes a recursive call to process the files in it. In C language I would replace that vector with a linked list if you need to keep the list of all files in memory for some reason.

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

>>And to clarify, if you do this you should initialize i as 0 or it will hold random numbers.
No you don't want to initialize the value of i to anything because it will contain the correct value from the previous loop.

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

You have the wrong idea about that parameter. It's supposed to be a pointer to an integer that you declare in your program. Read the man page for more information pid = wait(&status)

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

Step 1: read the two numbers on the first line. Name the variables x and y. Then allocate a 2d array of that size

int x,y;
// read x and y from file not shown here
int **matrix = 0; // this is the matrix you need to allocate

// allocate the rows of the matrix
matrix = new int*[y];
// allocate the columns
for(int i = 0; i < y; i++)
  matrix[i] = new int[x];

// now you should be able to read the remainder of the file into that matrix
// and do other calculations
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you posted the header file for bzlib.h but where is the source file? That header file is useless if you don't have the source file(s) or library that implement all those functions.

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

Check this thread out -- it was written in c++ but could be easily ported to C. If you read the code you will discover that it uses recursion to crawl though all sub directories.

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

I've done that with VC++ 2010 Express and never had a problem. For some reason your compiler is attempting to get something from Microsoft Windows SDK that is installed on your computer.

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

Your program looks nice, but still has one big flaw. What will happen if I enter a 99 or a negative value? After cin you need to verify that num is between 1 and 12.

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

You have to tell stringstream that the string is in hex fomat ss >> std::hex >> output; And include <iomanip>