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

Read in your textbook or online about the parameter to ins.get() -- it takes a pointer and you are passing a char. Whenever you get an error like this one you need to look up the function in your textbook or google for it so that you can verify for yourself that you have the right or wrong parameters.

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

Alex: I tried changing that but it didn's help. I posted a question on MySQL developer's forum, maybe they can tell me what's wrong. If, and when, I find out I'll post the answer here.

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

>>medalArray.country
That's the wrong way to access the array medalArray[i].country BTW: you should rename that array to something else to prevent confusion (you and your prof) between the structure name and the array name.

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

Yes I did all that -- I have the MySQL lib and include files in the MySQL 5.0 server folder. I just now tried a small C program totorial I found and it won't link either

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <winsock.h>
#include "mysql.h"

 MYSQL *mysql;
 MYSQL_RES *results;
 MYSQL_ROW record;
  static char *server_options[] = {"mysql_test", "--defaults-file=my.cnf"};
  int num_elements = sizeof(server_options) / sizeof(char *);

  static char *server_groups[] = {"libmysqd_server", "libmysqd_client"};


 int main()
 {
   mysql_server_init(num_elements, server_options, server_groups);
   mysql = mysql_init(NULL);

   mysql_options(mysql, MYSQL_READ_DEFAULT_GROUP, "libmysqld_client");
   mysql_options(mysql, MYSQL_OPT_USE_EMBEDDED_CONNECTION, NULL);

 }

1>main.obj : error LNK2001: unresolved external symbol _mysql_options@12
1>main.obj : error LNK2001: unresolved external symbol _mysql_init@4
1>main.obj : error LNK2001: unresolved external symbol _mysql_server_init@12
1>C:\dvlp\MySQL\Debug\MySQL.exe : fatal error LNK1120: 3 unresolved externals

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

Has anyone been able to compile the lib files using Microsoft Visual C++ 2008 Express compiler? I downloaded and installed MySQL 5.0 Server yesterday, then downloaded MySQL++ source. Attempted to compile and got a bunch of link errors. I used dumpbin.exe to get a list of all the symbols in libmysql.lib and noted that the function names did not have _ in front of them, but the symbol names the compiler's linker was trying to find did have the underline.

Is there a way to force the compiler to NOT put the underline in front of symbol names so that the linker can resolve the symbols in the libmysql.lib library?

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

Are you trying to use the WinCE emulator or an actual device? The emulators don't support a lot of stuff that the actual devices do mainly because emulators don't have access to the hardware. But I don't know if that's your problem or not. And not all devices that run WinCE are the same -- so what works on one manufacturer's device may or may not work on another. For example the scanners made by Symbols Technologies is a lot different than those made by Intermec. We had to make a lot of program changes when porting from one device to the other.

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

>>turbo c? (c++ 6.0)

What is that? Are you talking about two different compilers -- turbo C and VC++ 6.0 ? You can not use gotoxy() with VC++ 6.0 compiler.

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

>>Are lists stored the same way,
no. Lists are linked list and each node has its own memory location.

>>But, I have also read that the memory that was previously used can only be filled with a vector that is small enough to fit in the old space.
The old memory is given back to the program's general memory manager, which can use the space for anything.

>>I think that repeatedly using push_back() on a vector is less efficient
Yes, sizing the vector before doing anything is a lot more effiecient then a lot of push_back() calls. But in order to do that the program needs to know how big an array to create. If the array size is not known then there may be no other choice but to use push_back().

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

use getline() to retrieve the entire line as one string, then run it through the code I posted. instead of writing each individual string with cout put it in the array like you previously posted.

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

Yes, Niek, your solution is much better than mine. :)

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

1) It shouldn't matter if the length of the search string is the same as the replacement string. When the search string is found, copy the original string up to the beginning of the search string, then append the destination string, finally move the pointer past the end of the search string in the source string and append the remainder of the source string.

Example: NOTE: I didn't compile or test this, so it could contain one or more bugs. But the algorithm should be ok. I used strcpy(), strcat() and strlen() for brievity, but you may have to use your own functions in your assignment if that is what your prof required.

char temp[255] = {0};
char source[] = "Once upon a time there were three little pigs";
char search[] = "time";
char replace[] = "How now brown cow";
char *ptr1 = 0;
char *ptr2 = 0;
// find the search string in the source string
ptr1 = source;
while(*ptr1)
{
     if( *ptr1 == search[0] )
     {
           int i = 0, j = 0;
           while( search[i] && ptr1[j] == search[i])
           {
               i++;
               j++;
           }
           if( search[i] == 0) // end of search string, then we found it
           {
               *ptr1++ = 0; // truncate source string at point of search string
               strcpy(temp,   source ); // copy 1st part of source string
               strcat(temp, replace );  // add the replace string
               ptr1 += strlen(search) // advance past end of the search string
               strcat(temp,ptr1); // add rest of source string
           }
      }
      ptr1++;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

don't use strtok() on std::string objects because strtok() will put 0s in the string which will invalidate the std::string object.

The c++ way to achieve this is

int main()
{
    string str = "123 Mike November,12 1990";
    size_t pos = str.find_first_of(" ,");
    while(pos != string::npos)
    {
        cout << str.substr(0, pos) << "\n";
        str = str.substr(pos+1);
        pos = str.find_first_of(" ,");
    }
    cout << str << "\n"; // display the last word in the strihng

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

Do you know how to calculage an average? Total / number of items. So to get average weight you need to loop through the array summing up the weights, then divide that sum by the total number of weights. Same with height and bmi.

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

The win32 api function you want is SetSystemTime()

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

Why XML format? Look at these memory mapped files links

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

There is lots of information on the web that explains those things for you. Just search google

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

I have latest Firefox 3.0.1 that I installed just a couple days ago and IE7, but I don't see much difference speedwise. They are both about the same on my computer.

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

You first need to write a function that returns the factorial of a number. Be careful here because those values will grow very large very quickly. Calculating factorials in c++ programs has lots of limitations due to small numeric sizes. See limits.h for the maximum size of an integer or other numeric variables.

Once you have that, the rest should be pretty easy.

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

>>I almost completed the system
You still have more clean-up work to do.

1) stop using gets() and fflush(stdin). . You are writing a c++ program, not a C program. So replace gets() with cin.getline(). And read this thread how to flush the input stream.

2) Login problem. You need to either add more code that allows people to set up a login account, or just manually add the information to the text file.

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

google for ODBC. There are some free c++ classes that will help you.

Do you know the SQL language? If not you need to google for that too.

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

>>If there any function in C++ or C to resolve the problem
Nope. The only way to get rid of characters is to completly rewrite the file, unless the characters happen to be at the end of the file.

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

you need to use FILE*. On program startup, attempt to open the file for reading. If successful, then do what you mentioned. If not, then the file doesn't exist.

>>Which function i need to use? and how?
This is just normal file i/o stuff that should be explained in your textbook.

fopen() -- opens the file
fread() and fgets() -- reads the file
fwrite() -- writes the file
fseek() -- move file pointer around the file
fclose() -- close the file

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

how to do tasks 3 and 4 depends on how you implemented the previous tasks. You will be using many (if not all) the features you posted in those functions.

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

binary files do not contain characters as such, and attempting to count them in binary files is meaningless. But nonetheless, you can use stream's get() function to read the file one byte at a time. Just be aware that binary files contain lots of unreadable bytes.

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

pdf's and images are not text files, so they have to be opened in binary mode. For them you will have to use the stream's read() function. getline() is of no value to binary files.

If you just want the file size (which is a count of every byte in the file), just seek to the end of the file and get the file position.

ifstream in("filename", ios::binary);
in.seekp(0, ios::end);
int file_size = in.tellg();
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

getline() will get an entire line, including white spaces.

ifstream in("filename");
std::string line;
int counter = 0;
while( getline(in,line) )
{
    counter += line.length();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In MS-Windows and *nix operating systems a program can only write to memory that it ownes. The old MS-DOS days are gone forever, so writing to specific memory addresses as it was possible in MS-DOS 6.X and earlier is just no longer possible. And assembly would be of no value for this either.

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

I guess you would have to convert the number to a string and then return the length of the string. For example hex digits can't be represented by a simple integer -- only strings.

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

>>fgets fails to work completely as advertised,
Nope -- it has been working correctly for millions of programmers all over the world during the past 25 years. If there was a bug in fgets() then it would have been found and corrected years ago. The problem is in your program, not in fgets().

>>fgets(mystring,9,fp); //I actually only want 8 characters, but fgets fails to work as it should, and only picks up 8

You declared mystring too small. If you want 8 characters in it then you have to declare the string to be at least 10 characters. fgets() may or may not append '\n' to the end of the string, depending on if '\n' is encountered in the file. It also appends the NULL string terminating character.

When dealing with character arrays its better to declare the array too big then too small. If you are going to err, then make it on the generious side.

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

I can only give you a vague answer because of your vague question

addContact: Information can only be added to the end of the file. How to do that depends on how the file is opened. See the open flags here.. My suggestion is to use the "a" flag so that the os will write all data to the end of the time.

deleteContact: There are several ways to handle this
1) Completly rewrite the entire file, leaving out the information to be deleted.

2) Write a special character to the beginning of a record that acts as a delete flag for the rest of your program. Other parts of the program that reads the file should just ignore records that have the delete indicator (flag) set. This is one method that is used when dealing with large files.

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

you must mean the number of digits in a number,
You're program is almost right, except the while statement should check for t > 0, not t >= 10. That function doesn't need variable t at all, just use the parameter variable x.

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

>>i need to include the last update date and time of the record in the form of dd-mm-yyyy,hh:mm:ss(it has to be updated by th program automatically) and i don't really know how.

Just add another field called UpdateDateTime (or whatever you want to call it) to each record which would be time_t. When you write a record get the system's time using time() function from time.h and save it to the field along with all the other information. If you don't want to save the date/time as an integer then you can call localtime() that returns a string and save that, but it will take up alot more space in the file.

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

It really depends on what you mean by zero-length string and how you want to use it. If its the source string in the functions you mentioned then yes, they can be safely used there. But if they are the destination string, then safety will depend on how the string was declared.

char str[1] = 0; // zero-length string
strcpy(str, "Hello"); // this will crash your program

char* str1 = new char[255];
str[0] = 0; // make zero length string
strcpy(str1, "Hello"); // this is ok
strcat(str1,"Hello"); // this is ok too


char another_str[255] = {0}; // zero length string
strcpy(another_str, str); // this is ok
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Sorry to tell you that the only way to add something to the beginning of a file is to completly rewrite it.

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

What part(s) of the assignment don't you know how to do? main() has two optional parameters -- argc and argv. int main(int argc, char* argv[]) argc is the number of parameters on the command line -- normally it is a minimum of 1, but on some embedded systems it could be 0.

argv is an array of the arguments.

In the example you posted,
argv[0] == main
argv[1] == input.txt
argv[2] == output.txt

no just create an ifstream and an ofstream object using argv[1] and argv[2] as the filenames.

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

>>I dont know where I am going wrong. any help is cool

The first error tells you what is wrong. You can't have two functions that differ only by their return type. Overloaded functions must have different parameters.

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

Urgent for you maybe, but not for me. Just what do you want us to do with those requirements ?

BTW: you failed to post the equation that calculates BMI

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

You need to use the pointer cout << " " << it->time; or like this: cout << " " << (*it).time;

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

Curious... do you only see when one political side does it?

No -- it doesn't matter who does it.

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

You are right about the DLL. If you make it a static library you don't have to do any of that. Just compile the files as is then link your main.cpp with the library.

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

That is apparently a Nero CD-Image File Go to task manager and see if Nero is running on your computer.

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

>>Ancient Dragon been ignoring updates?
Never. I download and install all critical updates as they become available. I have my os set to auto update from M$.

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

>>or am i just exaggerating this thing?
You are misunderstanding the difference. The presence of a lot of member functions has nothing to do with efficiency. If you just want to use structures and pure win32 api then IMO write a C program, not C++.

MFC itself is pretty in-efficient. Its a handy set of c++ classes, but not very efficient. So to quibble about the difference of using RECT or CRect isn't really very productive. If your program requires efficiency and speed, then ditch MFC and use something else, such as wxWidgets.

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

>>first of then strlen only counts the characters in the first word of the line I put into console
The problem is your code, not strlen(). The >> operator stops accepting data from the keyboard when it encounters the first space or tab. All the rest of what you typed is still in the keyboard buffer. If you want all the spaces too then you have to use cin.getline() with character arrays or std::getline() with std::string.

Correcting that will also probably fix the other problem.

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

It simply shows that she is a well read person. I am sure she wouldn't ban any of these books without having them read in all details. There is a difference between banning a book and burning it. Looks like she likes books about guns and hunting more.

Censorship is censorship is communism. She may be a great mom, a great wife, a great hunter, but anyone who advocates censorship of any book doesn't belong in the white house. My wife is a great mom and wife too, but I wouldn't vote for her either :)

What do we really know about Sarah Palin other than "loving mother, apple pie, articulate thinker all rolled into one". Answer: Not a damed thing. But I'm sure we will find out in the next couple months.

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

IMO use MFC objects when available. In the two cases you cited it doesn't really matter to the compiler, it just makes your program more consistent if you use the MFC objects.

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

Hey Snee, keep from badmouthing Sarah Palin. She is a true hero, loving mother, apple pie, articulate thinker all rolled into one, and would make a great President. If only old McCain would have the decency to step aside before the election.

Says who???

Books Palin tried to ban
(This information is taken from the official minutes of the Wasilla Library Board).

Some are obvious. Others just don't makes sense. In any case, she had no right injecting herself in the library. Shades of nazism all over again!


A Clockwork Orange by Anthony Burgess
A Wrinkle in Time by Madeleine L'Engle
Annie on My Mind by Nancy Garden
As I Lay Dying by William Faulkner
Blubber by Judy Blume
Brave New World by Aldous Huxley
Bridge to Terabithia by Katherine Paterson
Canterbury Tales by Chaucer
Carrie by Stephen King
Catch-22 by Joseph Heller
Christine by Stephen King
Confessions by Jean-Jacques Rousseau
Cujo by Stephen King
Curses, Hexes, and Spells by Daniel Cohen
Daddy's Roommate by Michael Willhoite
Day No Pigs Would Die by Robert Peck
Death of a Salesman by Arthur Miller
Decameron by Boccaccio
East of Eden by John Steinbeck
Fallen Angels by Walter Myers
Fanny Hill (Memoirs of a Woman of Pleasure) by John Cleland
Flowers For Algernon by Daniel Keyes
Forever by Judy Blume
Grendel by John Champlin Gardner

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

I use dev-c++ - so mingw compiler. You'll see that the code you posted doesn't have an explicit return statement for every possible path; i.e. the function can hit the end brace '}' without executing a return xx; statement. I'm assuming that it works for you because your compiler doesn't modify the return register (EAX isn't it?) as drills back up through the nested function calls.

It worked for me only because I was lucky, not because the code was correct.

Line # 18 of the code quoted in previous post should have had a return statement to make it correct.

Big-noter!! Size isn't everything!

The only reason I mentioned it was because possibly the OP was running out of memory. recursion does that on computers with small ram.

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

No its not undefined -- the last else statement will take care of that case. The line you added will never get executed.

This statement isn't correct. Using Dev-C++ the function returns an undefined value without the return statement Dougy83 added.