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

That is a unix os api function which can be called from C if you are compiling for *inix os. just google "man getpid"

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

after about a year of intense training in C#, java and html you MIGHT be ready for that interview (entry level job). And don't forget to practice by setting and maintaining your own web site so you have something to show prospective employers what you can do.

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

the best solution to the problem is to always run a good antivirus program and to not visit risky web sites such as those porn sites.

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

thanks for the tip.

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

safest way is to reformat the hard drive and install everything all over again. You need to back up important files first. If you don't want to do that, then you can just delete the directory that contains the os you do not want, then edit boot.ini file in the c:\ root directory and remove any references to that copy of the os. But of course that will not remove the os from the registry.

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

you can't just convert the int by typcasting because (1) an int is a non-printable value and (2) the value of the integer may not be in the range '0' to '9' (single digit value). The safest way is to use sprintf() to format the string with an integer. I would suggest creating another temp char buffer to format the integer.

char tmpbuf[40];
sprintf(tmpbuf,"%d", length);
// now copy tmpbuf into buffer just like you
// do the other strings

Of course, if you absolutely know the integer is a single digit, then just add '0' to it.

len_char = (unsigned char) (length + '0');
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Its true most sites have bad examples, and Microsoft is no exception. Your best bet if you are just learning is to study good and reliable text books. Microsoft documentation has greatly improved over the past 10 or so years. Some examples are still questionable, but they have cleaned up their act and most function descriptions are now accurate.

BTW: I always include pragma to remove those warnings about deprecated functions because it is only Microsoft, not c++ standards committee who made them like that. The functions they suggest with "_s" are Microsoft specific and will probably not compile with any other compiler. So I think you are better off not using them.

#pragma warning(disable: 4996)
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Not sure what causes it but sometimes the computer refuses to shut down. The only way out is to physically press the Off button. I have XP Pro with SP2, Norton Antivirus and Norton Firewall, AMDI 64-bit processor with about 1Gig RAM, 30 Gig hard drive (master) and a 235Gig hard drive (slave). About the only software installed are a couple c++ compilers, Office 2003 and MySql server, but the computer is NOT used as a database server.

Any suggestions what to do about this problem? I just refrmatted and reinstalled everything about a week or so ago.

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

Dont hurt yourself with Windows firewall it's too broken get ZoneAlarm and AVG, dump Norton completely. If you need help doing it get at me.

Oh! great!:rolleyes: Now you all tell me that after I just bought Norton Internet Security suit.

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

XP64 ? I don't think there is such a product. I run XP on a 64-bit processor if that's what you mean. Or do you mean Vista, the next Microsoft 64-bit version of windows, and its still in beta testing so I would expect it to have bugs.

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

derive the class from CFormView instead of CDialog and MFC will put scroll bars on it and handle them appropriately for you.

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

you can use a loop. Something like below. The find() method will search one string for an instance of another string and return the position where its at.

string str1 = "ABC";
string str2 = "BCD";
string result;

for(int i = 0; i < str2.length(); ++)
{
   if( str1.find( str2[i] ) != string::npos )
       result += str2[i];
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

the compare() function is not what you need. It only tells you whether one string is the same as the other. you need to check the two strings one character at a time and create a third string that contains the characters which are in both strings. For example, the first two strings have the letters 'A' and 'M' in both strings, so a third string will contain "AM".

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

You guys convinced me that it's more than just Dave who wants color (Sorry to single you out, Dave). Color has been restored.

Thank you.

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

The free Express edition is better for beginners because it doesn't cost anything except download time. Use it for awhile and if you like it you can always buy the Standard or Pro edition. The Express edition does not include some whissles-and-bells that the standard edition includes, but beginners don't need those anyway. The most important thing right now is to learn the C and C++ languages, and the Express edition will allow you to do that quite adequately.

Also, the Express editon contains the same basic compiler that all the other editions contain. The difference between the editions is not the compiler but the add-ons, such as Microsoft Foundation Class (MFC). You don't need all that just to learn the language.

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

I just tried to use color and found out, sadly, that I no longer works. I tried it four or five times before deciding to come to this board to complain -- and found this thread at the very top!

I don't see what the problem is -- so what if someone wants to waste a huge amount of time colorizing every other word, or even every other letter? Does it impact on the performance of the web server? If not, then why limit it?

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

1. Your program suffers from the same bug that gets() contains -- it will allow you to enter more characters than can be held in the input buffer. The do-while loop needs to check that buffer overflow does not occur.

2. The input buffer is not null-terminated, which might explain why the final printf() displays incorrect information. You can easily correct this by

char str[20]  = {0};

3. The program does not handle backspace and arrow keys. So if you make a typing mistake there is no way to correct it.

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

>> cant get the rest to work

what parts can you make work? what have you tried? what part(s) of the requirements do you not understand?

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

free() does not necessarily give the memory back to the os. C programs normally have a pretty efficient memory allocation algorithm, it does not release memory back to the os when deallocated by free(), but instead keeps it in a free list so that it is readily available the next time malloc() is called. So an external program monitoring the memory usage of another program may only be able to detect when new memory is grabbed from the os and not when free() is called.

I'm not a unix or HP expert, but you might check around to see if you can find a program that can detect memory leaks. For example, this article might be useful to you. And you might read some of the articles in these google links. Some of them apply to other operating systems which you can just ignore.

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

what operating system and compiler? Might be that your program is fragmenting memory very badly or more likely your program is not freeing memory correctly. You might try allocating just one huge block of memory then allocating it among all those nodes.

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

close. After this loop finished, counter will contain the number of elements read, so you should use that variable instead of SIZE when searching the array.

add #include <fstream>


ifstream in("C:/path/to/text/file.txt");
int counter = 0;
while (counter < SIZE && in >> bench[counter] )
{
    counter++;
}
in.close()
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Use ifstream to open and read the integers from a text file into an array. Your program should have a loop that will read a single integer and insert it into the next available index of the array. I'm sure your text book has examples of how to do something like that.

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

>>Also, #include "stdafx.h" i not necessary

It is with VC++ compilers and have precompiled headers turned on.

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

Suggestion: compile and run the program and you will see for yourself what will happen. Of course just getting it to compile without errors will be your first task.

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

jan@jan-desktop:~$ ./a.out <Enter key>
bash: syntax error near unexpected token `newline'

I did not mean for you to type "<Enter key>" on the command line -- that only meant that you should have hit the Enter key on the keyboard. If you actually typed that text, then try it again without that part. just

$ ./a.out
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Its good that you are going to buy a book, that's the best way to learn. But that book won't teach you a thing about gcc compiler or how to use linux. you need to learn how to compile and execute a program before that book (or most any other book for that matter) will be much help to you.

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

probably because you can't include that file (wingdi.h) directly in your program. include windows.h instead, and it will include all the necessary header files.

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

Use ls command to search the directory and see if it contains a file called a.out. If not, then gcc probably did not compile it. If it didn't then compare your program with what ~S.O.S.~ posted and make sure it is identical. And from here I think you need to start reading some of the links that were posted in the sticky at the top of this board. I know its a lot of reading, but if you want to learn how to program you must also be willing to do a lot of reading and studying.

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

gcc only compiles your program into an executable file, it does not run your program. The default name of your program is a.out because you did not tell gcc what to name it. So to run your program, try this:

./a.out <Enter key>
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you need to repost your program because I can't see it from where I am sitting.

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

you probably forgot to include stdio.h. Add this as the first line of your program

#include <stdio.h>
// rest of your program goes here
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't know anything about them so I can't answer that question. Most people, including me, just creat a console window and run the scripts from command prompt as shown in that tutorial.

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

more than likely you will be using the common gcc compiler. Here is a short tutorial to get you going.

you should also read the sticky threads at the beginning of this board, including this one which contains lots of links to other programming articles and tutorials.

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

what version of the compiler are you using? Have you installed SP5 bug fixes? I have VC++ 6.0 with SP 5 and do not have your problem.

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

Sorry about the mistake. Should have been GetDlgItem

Alternatively, if you used ClassWizard to assign a CString variable to the edit control, then you don't need to call GetDlgItem() but use that variable instead, then call UpdateData(FALSE) to update the edit control.

If you are new to MFC and you are using VC++ 6.0 compiler you might want to read the Microsoft Scribble tutorial, which will show you how to do all that neat stuff.

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

>>why can I adding them to the case WM_CREATE to realise it?

You want to do painting in the WM_CREATE event message? you can't do painting there because the window has not yet been created.

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

you will have to format the string before it is displayed in the dialog box. If you are using MFC, then use CString's Format() method, for exaple

CString text;
float number = 12.123456;
text.Format("%.2f", number);
GetDialogItem(IDC_EDI1)->SetWindowText(text);

If you are not using MFC, then use standard C sprintf() function

char text[20];
float number = 12.123456;
sprintf(text,"%.2f", number);
GetDialogItem(IDC_EDI1)->SetWindowText(text);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you are using VC++ 6.0 compiler the path should already be set. Look in menu Tools --> Options --> Directories -->Include Files. There you will find the path. If it isn't there then you need to put it there. Should have been set during the compiler's install, but maybe you accidentially deleted it.

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

I've been asking that question for the past 20 years and nobody has ever come up with a good solution. There is no one method and some methods work better on some projects then others. First you have to decide what the program is going to do, be as detailed as possible. Write specific requirements out either on paper or in a word processor such as Notepad. If it is a Windows program then draw pictures of the windows and menus, then write out what each object in the window will do. Adding new requirements later is a major factor in failing to deliver software on time.

I'm sure there are a few books on the subject that you can get at your local library.

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

There is no quick and easy solution to your problem. As you have already found out just reading the data into integers doesn't solve your problem because the program doesn't distinguish one line from another. Only getline() can do that for you. Once the line is read, the line must be parsed to see if it contains any errors (or missing elements). Again, ifstream's simple extraction operator >> will not do that for you.

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

one suggestion: load them into a vector, sort them, then use a binary search algorithm to search for given string. But I suspect that is something like what a <map> would do for you.

Another suggestion: If the file that contains the 1.5 million records rarely changes, don't read them into memory. Write another small program that will be run only when the primary file changes. It will create an index file that contains fixed-length records with key string and integer offset into primary file where the record starts, sort the key file. Then in the main program you are writing use binary search to search the keys in the file. Since the index file will already be sorted when your program starts, you could just read the whole thing into a vectory and then do in-memory binary search. C++ std::string is a nice class, but will kill a program that uses millions of them. When reading the structure below don't convert the strings to std::string, leave them as c-style strings because they will load into vector a lot quicker.

struct keys
{
   char keystr[255]; 
   unsigned long offset;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I would use getline() instead of that loop, then parse the line just read

std::strine line;
while( getline(inp,line) )
{

   // check line for correct number of commas
   // count the number of commas -- should be 8 
   // and make sure the last comma is not the last thing on the line
   // if there are not 8 commas or the last comma is the last one on the
   // line, then continue to the top of this loop
   //
   // line is probably ok to use.  So now break it up into individul fields.
   // use std::string's find() to locate the position of the next comma, then    
   // substr() method to extract the text.
   // 
   // or use istringstream() -- but I'm not familar with it so someone else
   // can probably give you good example if you need it.
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

there should be no asterisk in front of node.

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

>>*node.name = *name;

name is declared as a pointer to a character array. *name is extracting just the first character of that array. You should change this line to

*node.name = name; // remove the asterisk

>>printf("Employee name: %s\n",*name);
the asterisk does not belong here either

printf("Employee name: %s\n",name);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think you need VC++ 6.0 compiler installed. I have 2005 express and it isn't in there. Nor is the *.dll in the c:\windows directory. So I suspece you are just SOL with that program and your compiler.

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

linkers do NOT link with *.dll files, but link with *.lib files. What, specifically, is "filename"? Is that something you just made up for posting purposes or is that what the linker actaully put in the error message?

>I do not see amy sort of system path in MSCONFIG to set.
Nor should there be. c:\windows\system32 is not intended for development purposes and there is nothing in that directory that your compiler will ever need.

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

try this

LPCTSTR lpszStr=(LPCTSTR)Rxg;

>>LPCTSTR b=d.Fun();

post the complete error message, I don't think you exported/imported the function correctly. This is a macro I use. When compiling the DLL, define the macro MYEXPORT, when compiling the application then do not define it.

#ifdef MYEXPORT
#define DllExport  __declspec( dllexport )
#else
#define DllExport  __declspec( dllimport )
#endif

class AFX_NOVTABLE dll 
{
public:
DllExport LPCTSTR Fun();
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

DO you really think I should use VC2005, I mean, compared to the VC++6.0 enterprise version, the free version seemed much less powerful

VC2005 is also a lot less buggy and conforms to ISO C++ standard much better. True, you can't do MFC with that free compiler -- you will need to buy at least the Standard edition to get that. Otherwise, VC2005 and the free Windows Platform SDK together will probably suit most non-comnmercial needs.

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

Those are copyright files and it would be illegal to post them on this web site. Why don't you just reinstall the compiler? Better yet, toss that old compiler out and get VC++ 2005 (Express edition is free).

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

does anyone review the code shippets that get posted? I was glancing through the list and found one that is full of bugs :eek: -- any newbe would have a difficult time trying to figure out how to correct the bugs. Not a problem for me, but just wondering if there is any peer review process before they get publically posted.