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

what compiler are you using??? The code you posted certainly will not compile with any standard C compiler because there is just too much missing, such as the data types of a, b, and c. And "x="%d"" is not even inside a function.

So don't tell us the program runs -- it won't even compile let alone run.

And Walt is right -- just delete the for loop statement and leave only the printf() statement.

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

I think you mis-read the chart. The Presidents are listed in chronological order of their administrations, not their popularity.

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

you need a loop. In the loop, move one character into the al register then compare al with whatever character you want. The following code isn't compretly correct but will give you an idea of what needs to be done

mov cx,length of string
loop_top:
   mov al,es:[si]; copy one character into al
   inc si;
   cmp al,'D' ; check if the character is the letter 'D'
   je loop_end ; go if it's the letter I want
   loop loop_top ; back to top of loop
loop_end:
   ;; do something here
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Who said Clinton was the 3d worst?? If you look at this scolarly chart, Reagan was ranked among the best, and Clinton was among the 2d best. there's a lot of red on that chart, but none of them belong to either Clinton or Reagan.

And read on down that page, a gallop poll in 2011 ranked Reagan as THE greatest president ever (19%) followed by Lincoln (14%) and Clinton (13%).

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

You are right -- should have been strcspn, not strchr

>>and the input stream post is really big even thought i scheme through few pages i could not get anything

What don't you understand about it?

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

>>x="%d";main(b,a,t)

Huh? Don't know what that is.

>> for(scanf(x,&a);a>0;a=0)
Odd loop -- assuming a starts out to be greater than 0, the loop will execute exactly one time. Don't you want to change "a=0" to a-- ?


I would assume the code also has to compile cleanly ( 0 errors and 0 warnings).

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

The command-line compiler is cl.exe. In a command prompt window (DOS box), first run vcvars32.bat found in the compiler's install bin directory. That will set all the environment variables needed to run cl.exe

cl.exe uses many of the flags that are commonly found in make files. /I followed by include directory, and /L followed by library directory. So if you want to compile and link myprogram.cpp with mylib.lib cl myprogram.cpp mylib.lib -o myprogram.exe /L c:\mylibs This can all get very complicated if you don't use a makefile and nmame.exe utility.

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

Reagan was probably one of the best presidents in my lifetime, including JFK. A long-time movie star he knew how to capture his audience, for example this YouTube clip

jwenting commented: vive la Reagan Revolucion! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>What on Earth are you talking about? There are robust cross-platform libraries for everything in C++

Agreed, but the libraries are os-specific. If you are going to write a library then you most likely will have to use os-specif function calls. If you look at the source code for boost libraries I'll bet you will find os-specific functions. That is what I had in mind.

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

rep movsb is explained here. If you are going to write inline assembly then you have to know assembly language itself.

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

Did you try google

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

I don't think there is anything like that for c++ because c++ programs are pretty much operating system specific. Yes the language itself is os independent, but to make c++ programs do anything worthwhile they have to make os-specific function calls, and the programs have to be recompiled for each target platform.

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

you only have 30 minutes to edit a post. After that you will either have to make another post to correct errors in the previous post, or report the post (hit the Flag Bad Post button) and explain what you want the mods to change. Whether they will change it or not is up to them.

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

Oh I give up too. I tried to help but all I got was shit. Let him solve the problem himself.

VernonDozier commented: Everyone here knows you're not at fault. +13
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I agree with Fbody that you probably have multiple copies of transinfo.txt. Suggest you search your hard drive and delete all of them except one.

And try being a little nicer, or you might find yourself banned for awhile.


>>thanks everyone else who's not a d-bag like A-Drag
I'll have you know I'm no d-bag. I'm an ass hole, or so I've been told. But did I post profaniy??? NOoooooooooooo. Now whose calling the kettel black.

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

Are you using MAC? I'm using Windows 7 and VC++ 2010 Express.

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

Looks ok for me (using IE8). Its a round white circle.

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

This is what I got when I ran your program. What's wrong with it?

0 0
1 0
2 0
3 0
4 0
5 0
6 0
7 0
8 0
9 0
23503Receive 50 units of car 3
1Receive 75 units of car 1
0Receive 40 units of car 0
3Sell 25 units of car 3
5REJECTED: Insufficient Stock
6Receive 50 units of car 6
8Receive 300 units of car 8
3INVALID TRANSACTION CODE6
0Receive 30 units of car 0
2Receive 10 units of car 2
6REJECTED: Insufficient Stock
4Receive 30 units of car 4
6Receive 200 units of car 6
5REJECTED: Insufficient Stock
6Sell 100 units of car 6

0 70
1 75
2 10
3 25
4 30
5 0
6 150
7 0
8 300
9 0


Total potential income: 450000
Press any key to continue . . .
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Everyone will just ignore you when you use such cursing.

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

Are you required to use inline assembly for this program? It's so simple in C, why do it the hard way??? printf("what is %s and where is %s", argv[1], argv[1]); In any event, you need to use a loop to copy the characters, or you can set up the call to rep movsb.

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

>>Am doing migration from 16 bit code to 32 bit... help me to solve the issue...
There were some very major changes to MFC between the two versions. Which 32-bit version of the compiler are you using? I hopt it will be vc++ 2010.


Look up the function GetFirstDocTemplatePosition() and you will easily see what the problem is. This should have taken you no more than 60 seconds to find the problem with your code. Once you get the POSITION returned by that function you have to call GetNextDocTemplate() to get a pointer to the CDocTemplate class in which the CPtrList object exists that you are looking for (there could be more than one CDocTemplate objects in the program). Once you get that, you can typecast it to your specific document class (CDocument is derived from CDocTemplate), such as CMyDocument, and that will let you gain access to the CPtrList object in the document.

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

Here's a hint how to do it

Here is how to code the structure

struct Book_Record
{
    int ID;
    float price;
    char requestor[80];
    char call[4];
    char invoice[20];
    char supplier[40];
    int copies;
    float total;
    char published[25];
    char date[20];
    char isbn[20];	
    char name[40];
    char author[40];
    char category[20];
    char publisher[40];
    bool deleted;
};

Below is the first part of the Add fucntion. You should be able to use this as a pattern for coding the rest of that.


Don't use getline(cin,dummy) to flush the input stream. That will make you enter the same string twice if there's nothing in the input stream. See this thread how to flush cin.

case '1':		
	cout << "\n\n\n";
	cout << "\t***********************************************************" << endl;
	cout << "\t***********************************************************" << endl;
	cout << "\t***                                                     ***" << endl; 
	cout << "\t***                Add new records                      ***" << endl;
	cout << "\t***                                                     ***" << endl; 
	cout << "\t***********************************************************" << endl;
	cout << "\t***********************************************************" << endl;

			cout << "\n\nBook's ID<AutoGenerate>: ";
			Book.ID = Auto++;
			cout << Book.ID << endl;

			if (output.open("id.txt"),ios::out)
			{
				output<<Auto;
			}
			else 
				cout << "The file is empty.";
				output.close();

			cout << "Enter Book's NAME: ";
			//getline(cin,dummy);
			cin.getline (Book.name, sizeof(Book.name));
			while (strchr(Book.name,"qwertyuiopasdfghjklzxcvbnm1234567890-+") != NULL)
			{
				cout << "Invalid input! Please enter again! NAME: ";
				cin.getline (Book.name, sizeof(Book.name));
			}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

MySQL is very popular. But I don't know what you mean by "light". Its either SQL compliant or it isn't. I also don't know about its ability to recover after a crash. Since its so popular I can only assum that it can do it.

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

>> The file names are specified on the command line:

That means you need to declare main() with two arguments -- argc and argv. argv[1] is the input file name and argv[2] is the output file name. Your program should not prompt for these names.

>>cout << "Enter <strong class="highlight">the</strong> input <strong class="highlight">file</strong> name:


Huh??? what is "<strong class= ... " business? You are supposed to be writing c++ code, not html.

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

The problem is that the structure contains std::string objects, which can not be written to binary files like that. You need to either change the structure by replacing std::string with fixed-length char arrays or change the way the files are written, which can be somewhat tricky with std::string. IMO the simplest way to solve the problem is to change the structure

struct Book_Record
{
int ID;
float price;
char requestor[80];
char call[4];
char invoice[80];
// etc etc for all the rest of the structure members
bool deleted;
};

The next thing you will have to do is make minor changes in the rest of the code to call strcpy() in order to copy the strings into the structure. For example, instead of getline (cin,Book.name); you will have to do something like this:

getline(cin,dummy); // where dummy is std::string
strcpy(Book.name,dummy.c_str());

There are some pitfalls in using strcpy() like that -- you have to make sure the length of dummy does not exceed the size of the character array. In the example above, you need to make sure dummy.size() < sizeof(Book.name). That means more error checking in the Add function of the program.

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

Like the "security policy" where I now work, which means I've been waiting since early February for the permissions to upload and compile sources on our development server, causing several months delay and massive cost overruns on the project.

Oh, you must be working for US governmemt or one of its contractors. Been there, and done that. But I understand why, because they get too many hackers and viruses. But I'm not sure the cost is really worth it.

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

That's a very very broad subject and could probably write a whole book about it. Re-think it like this: how does the policies of your school affect you? Basically the boss will tell you "Follow my policies or else -- if you don't like them then go work somewhere else."

Maybe you should narrow down the topic to something more manageable.

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

Add the code as an attachment to your post. We don't want to scroll through all 1,000 lines of code. Just use the Advanced Editor, scroll down until you see the Manage Attachments button then from that you can upload the *.cpp file.

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

>>I can't and I won't translate all of that into English because it's irrelevant. I
Then why did you post the link if its not relevant information? But let's not get hung up on that.

>>Why do I need it?
I have no idea. Its your program not mine. Ask that of whoever designed the program requirements.

>>BUT my problem is the GetMyMsgName() / GetMyMsgText() always return null or I don't know how to use them.

Most likely because those two variables have never been initialized to anything. Check the class constructor.

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

>>but my problem is if i input this one i have to go through the whole program and i donot want to do that

Yes, I mean like the code you posted. If you don't want to do that then I don't want to help you. I'm not going to waste my time trying to figure out a program that has 550+ lines all in the same function.

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

Finally someone had enough smarts to know what a RAM disk is. I suspect only us older people have ever heard of it because its only supported on 16-bit MS-DOS operating system, which used randrive.sys file at boot time. AFAIK they can not be created in 32 or 64-bit os. You might want to read some of these google links for more information.

[edit]Looks like there is a way to do it, but you will have to experiment with it yourself. As for writing the code yourself, good luck because it may involve a large amount of assembly language and kernel level programming.

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

line 77: what will that do if the value of namelen is greater than 255, the max value that can be put in a single character ?

You need to translate that link into English because I have no idea what it says, don't even know what language it is.

>>The problem is I can't/don't know how to use the char * returned by the GetMyMsgName() method

What do you want to use it for?

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

You need to learn to organize your programs a lot better than that. What will you do with a program that contains millions of lines of code? Put them all in main()??? Of course not. You need to learn to write functions that perform specific tasks. For example if you have a switch statement that contains 5 cases then you will want to write 5 functions, one for each case, and then call those functions from within the switch statement.

I briefly looked at the code you posted and, to be honest, it needs a major overhaul so that its more understandable and better formatted. I can see why you are having so much trouble with that program.

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

My guess is that you have not even attempted to compile that code. It contains errors that you need to fix. For example:

CMyMessage line 77: error -- you can not store a pointer in one byte of memory.

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

count them in a loop. Now post the code you have written if you have more questions.

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

why are you calling GetName() so many times??? And for what purpose is the second parameter to that function?

char* xxx = GetName();
if( xxx != NULL)
{
   printf("%s\n", xxx);
   memcpy(message+1,xxx,strlen(xxx));
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem with >> is that it doesn't stop at the end of the line. If all you want to do is read just won't on a line you can do anything like while( infile >> word)

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

Assuming there are other lines in the file that have other tags at the beginning of the line, I would use getline() to read the entire line, then use stringstream to split it up into words. If you just use >> operator you won't know the difference between lines -- getline() will give you that control.

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

you need both width and height so that your program knows how many lines of text to save. They can both be calculated when you know the upper-left and lower-right coordinates. It might be easier to just save the contents of the entire screen, write sub-menu, then restore the screen to erase the sub-menu. If you don't do anything with the color attributes than all you need is a buffer that's 24*80 = 1920 bytes. double that if you need the color attributes too.

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

Yes the reader should also lock with the mutex. I suppose you could have just one queue for all readers, as long as the objects in the queue have something to tell you what message goes to whom. Something like that is what MS-Windows does with the windows messages -- each message contains a handle to the destination window.

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

In DisplayData() you need a loop for(int i = 0; i < NUM_STU; i++) . Then within that loop diaply the loop counter followed by each array value

cout << i+1 << " " << student_avg[i] << " ";
for(int j = 0; j < NUM_QUIZ; j++)
   cout << matrix[i][j] << " ";
cout << '\n'; // move cursor to next line
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes I think its misplaced thinking. What if there are no items in the queue, and reader tries to read while writer tries to write? Everyone needs to be locked out while writer tries to write to the queue. Depending on how your code is written there could be more than one reader at the same time. But writer should have exclusive use of the queue data.

There are several ways to accomplish that. One way is setting up a mutex. Under MS-Windows another way is via CRITICAL_SECTION.

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

what's the value of es when that function is entered? The screen address is at 0xB800:0000, so you have to read starting from there. I think your function needs to set the value of es and not assume it already contains the correct segment value.

bx = upper left corner
ax = lower right corner
cx = width -- this is one problem. We need the height, not the width. The width can be calculated from bx and ax.

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

You can use some non-standard functions found in conio.h, assuming your compiler supports them.

time_t t1 = time(0);
time_t t2 = t1 + 60; // one minute timeout
while( !_kbhit() && t1 < t2)
{
   // do count-down timer
   Sleep(100); // delay 100 milliseconds
   t1 = time(0);
}

if( t2 >= t1)
{
   // timeout expired
}

// not do the cin stuf here
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I want absolute silence. Trying to write code while listening to anything is just too distracting because I tend to listen to music and not pay attention to what I'm coding. Its a little like trying to code while intoxicated. Can't be successfully done.

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

OMG I hope you don't have all that code in one function main() :icon_eek:

You could post it as an attachment, but don't post something that you may regret later because DaniWeb won't delete it.

Why allocate with new the stream objects? Waste of space and time. Just declare the object ifstream stream; The object is just a few bytes so there's no point in calling new to allocate it.

Remove those gotos -- they are not needed and you instructor may give you a lower grade for using them.

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

Elvis of course :)

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

>>1. i already have ("CLS") and ("cls") ( both of them but i do not know whats the difference) .

CLS and cls are the exact same thing. MS-Windows does not distingish between cases line *nix does.

>>will this cls duo make any problem for a 3rd one
what 3d one? All it does is erase everything on the screen.

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

A vector is an array of objects which handles most of the memory allocation and deallocation for you. There are several tutorials for vectors, just use google and you will easily find them.

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

I don't know how to initialize it, but try this and your solution doesn't work. My suggestion is not to put const variables inside structures. It wouldn't make any sense to put them inside a structure anyway because by definition you set a const variable to a single value which does not depend on any given instance of the structure. const variables have the same value for all instances of the structure and can never be legally changed. Of course you can typecast out the const and change it that way, but that's cheating.

struct mys
{
    char buf[255];
    const int value;
};