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

I am using Visual C++ version 6. I need to know how to add a .lib file to a project. I want to add it as a static lib file.

Project --> Settings --> Link Tab --> change Catetory to Input then add the library to the Object/library modules list. In the left pain, change Settings For to All Configurations

iamthwee commented: retarded -2
Duki commented: equilization at hand. :) +4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Same with identity cards
If you have a driver's license then you already have an ID card :)

>>or having to tell the government the moment I move house
Do you pay taxes ? Does the tax form(s) ask your address. If yes, then you do that doo.

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

If this is for a school assignment then you probably should not use the boost library without your instructor's prior permission because he (or she) may not be able to compile it on school computers.

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

offtopic but the wig looks pretty stupid... Do all UK judges wear them?

LOL -- I recently recarpeted my house with carpet that looks very much like his wig.

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

Isn't it somewhere in the book of Revelations (Bible) that indicates we are in our final days when people are required to have a number tattooed on the forehead? I'm sure you said that in jest, but then ....

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

What is a segway?

Didn't you look at the picture in that link ?:D

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

Odometer is the name of the class, not of an object.

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

But the link works perfectly for me.

It times out from here (USA).

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

you need to truncate the string at the spot where you want to stop printing. If you want the full string later then save that character in another variable and put it back after printing

char c[40], *pc, save;
int size;

scanf("%s", c);
size = strlen(c);
save = c[size-4];
// truncate the string
c[size-4] = 0;
printf("%s\n", c);
// now put it back
c[size-4] = save;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Have a look at this.

link doesn't work

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

c++ classes and their methods are not callable from C.

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

you created a windows program not a console program. The simplest fix to that problem is to start all over again, but this time when you get to the Application Settings window choose Console Application

[edit] what WolfPack wrote -- I didn't see it when I wrote this [/edit]


About the code you posted: If the file failed to open you can't write an error message to it. You probably want to use cout instead of the file handle that failed to open.

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

O.K., thanks!
I'm downloading it now, although it took time to find a link to it. It's well hidden from some reason.
I hope it's full enough.

Thanks again!

Please post link:)

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

And don't forget to close the file < CloseFile() > before leaving that function!

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

One thing that may cause that behavior is if the two functions are in different program units (*.c files) or libraries and compiled with different packing factors. Another cause is two functions in different program units using different versions of the same structure. Check your computer's file system to see if it has more than one copy of the header file in which the structure is defined. (Ben there, done that :) ).

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

The only two I have worked with are manufactured by Symbol Technologies and Intermec. Both cost several hundred $$$.

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

Also, Dani changed the rules a couple weeks ago and removed all rep that was given in Geeks Lounge. Many Members lost dots.

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

Of course it will work -- just fill in the SYSTEMTIME structure with whatever the user entered and call SetSystemTime(). I would first call GetSystemTime() to get current day, month and year, then change the other member values to whatever you want before calling SetSytemTime(). Note that SetSystemTime() expects GMT, which depends on the time zone. There are other win32 api functions you can call to get the computer's time zone setting. If your time zone is CST (USA Central Standard Time), you have to subtract 6 from the local time that the user enters.

Call SetSystemTimeAdjustment() to disable auto periodic time adjustments from outside sources because it will screw up your program.

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

win32 api SetSystemTime()

One problem with your program is that many computers automatically synchronize the system time with something else, such as a network computer or a satellite. In that case whatever you set the computer to will eventually be changed.

>> can't set the time during run time
why not? Its just a function that can be called anytime you want to.

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

i don't mean to offend you dragon if i did i am very sorry...

No offense taken and no need for apology. The solution I posted will get you all the files in the directory and all sub-directories and puts the file names in a std::vector. Might be a little too complicated for new programmers though.

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

Yes, call opendir() the readdir(). A complete workable example program is in the Code Snippets

>>i am using just a few functions of c++

That makes it a c++ program, not a c program.

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

>>Now some threads are labelled "Multi Page Thread",
I don't see that. Maybe its the way you have it set up in Control Panel ? I have Thread Display Mode set up as "Linear - Oldest First"

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

by tooltips do you mean the thread preview that follows the cursor around on the menu page ? Yes I don't like that either and find it not at all useful when there is more than 1 post in the thread. Its just annoying.

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

Miracle Whip (not mayo) is great on jello and sandwitches. Never tried it on eggs, but I think I will. I'll try almost anything at least once.

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

Here isspace is a character or a predefined constant in some header??

isspace() is a macro defined in ctype.h header file. It is also be implemented as a standard C function which is why it can be passed to another function as a function pointer. Its a platform-independent way of checking if a character is whitespace.

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

Or this to avoid break. Yes I like your suggestion. You don't need the function pointer variable.

void remove_ws( vector<string>& vertex )
{
  for( size_t i=0 ; i<vertex.size() ; ++i )
  {
      std::string& mystring = vertex[i] ;
      string::iterator where = mystring.begin() ;
      while( (where = find_if( where, mystring.end(), issspace )) != mystring.end() )
      {
        where = mystring.erase(where) ;
      }
  }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Now i have to again add this to the original vector how should i do that

Please re-read my previous post becasue I tested and changed it. That algorithm works.

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

Slightliy more complicated. You need to use a reference to the string in the vector. The algorithm below removes white space found anywhere in the string.

for(vector<string>::iterator it=vertex.begin();it!=vertex.end();it++)
{
    std::string& mystring = *it;
    std::size_t pos;
    while( (pos = mystring.find_first_of(" \t\r\n")) != string::npos)
    {
        if(pos > 1)
        {
            mystring = mystring.substr(0,pos) + mystring.substr(pos+1);   
        }
        else
        {
            mystring = mystring.substr(pos+1);   
        }
    }

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

post code and an actual example string. For example: "a b c" replaced by "abc". If that's what you want to do when code a while loop something like this:

string::size_t pos;
while( (pos = mystring.find(' ')) != string::npos)
{
    mystring = mystring.substr(0,pos) + mystring.substr(pos+1);   
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just because some programmers use goto in kernel programs doesn't mean its acceptable to use it in application programs. I've never written a *nix kernel program or even seen one.

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

They'll probably tell you to never use goto as well, but that doesn't mean you should just listen to them. Find out why, and then do what is best; and yes, the popular opinion can be wrong sometimes..

Most, if not all, professional programmers refuse to use the goto statement, and most companies will not allow it. If you are just learning programming for yourself and for the fun of it then by all means do whatever you want. But if you ever intend to make programming a profession then learn the best forms of coding and what to stay away from. Never use goto and never use void main(). Learn that now the right way and you won't have to unlearn it later in a couple years or so.

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

catsup and catchup is the same as Ketchup? :?: the tomato sauce?

Was just wondering :-/

Yes, they are the same thing. Read this article.

Sulley's Boo commented: Thanks! +3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>what i want to be sure is, after function statements does the allocation space dissapear

Yes because you sent the pointer by value and not by reference. You need to send a pointer to a pointer which requires two stars not just one.

Allocation(&ucBufr);


void Allocation(unsigned char ** ucBufr)
{
        /* nDataSize and ucData is got from a file here. */
        *ucBufr = malloc(nDataSize);
        *ucBufr[0] = 'B';
        *ucBufr[1] = 'U';
        memcpy(*ucBufr+2,ucData,nDataSize);
        /* ... */
}

>>local variables which are defined in the function are freed by the O/S
The OS does not do that for local variables but it will for memory allocated by malloc() -- local variables are freed by the program itself when the function returns to its caller and cleans up the stack.

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

I don't like catsup on either eggs or fries but I know a lot of other people that do. The only thing that goes on an egg is a muffin.

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

The value of x is uninitialized, and the value of y should start at 1 not 0. It might be better to use a for loop instead of a while loop.

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

>>i'm just trying to check my code u all if it's correct
does it do what its supposed to do ? If yes, then its ok. If not then you need to fix it. One problem though is that your program will produce data overflow errors if the value of n is too large.

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

We are not a software factury where you can get the answers to all the programs you teacher might ask you to write. Think about what you are required to do then write an outline of the program. After that you should be able to code the program. only when you show us your work will we help you.

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

>>The program works
No it doesn't.

you use gets() all over the place. Try entering some text that is longer than the buffer can hold and you will find that your program doesn't work afterall. gets() will just scribble all over memory with the extra characters and cause your program to crash at some point. The solution is to use fgets() instead to limit data input.

line 30: parameter to gets() is wrong.

in main() variable i is apparently being used to mark the next available slot in the prson array. But then you use i again for several other reasons. I think you need to set up a different variable for that purpose and not use it for anything else. You also need to verify that you don't try to enter more than 20 people because that's all the array can hold -- if you add the 21st person your program will crash.

As for your original question -- I think you need another menu option to show records for only a specific person then prompt for that person's name. Then its a simple loop to search the array for the person and print it when found.

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

see the instructions for int86() function. Google and you will see examples.

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

Additional question. Does ifstream reads a space as a beginning of a new line?

No -- when you use the extraction operator >> the stream only reads up to the first space. That is why I suggest getline() in my previous post.

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

If you use getline() on line 64 you will avoid the space problem. getline() will read the entire line, then you can separate it into comma-separated tokens.

Line 61 is incorrect -- you should avoid using eof() like that because it will cause problems. Use getline() instead, something like this

while( getline(str,inFile) )
{
    // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If that is the binary representation of the integer, then just typecast it or memcpy() it.

char array[some_number];

int n = *(int *)array;

or
memcpy(&n, array, sizeof(int));
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you have to understand a little about assembly programming. REGS is just a union on some integers that the function int86() uses to set up the microprocessor's registers before executing the interrupt instruction. google for dos interrupts and you will find this among many others.

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

post more code including how you declared matrix and swap variables.

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

line 5: swap should not be an array but a simple integer, like this:

int  swap = matrix[m][k];

then line 8:

matrix[m+1][k] = swap;

and don't forget to change line 9 too.

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

My guess is that you are passing the wrong data types to the function probably for the first parameter. Make sure the first parameter is unsigned int and not something else.

>>When I run the program I get this
No you don't -- you will get that error at compile time, not runtime :)

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

here's what the functions would look like

double sumArray(double a[LOCATIONS], double& totalSales) 
{

}

and here is how to call it from main () on line 44. And don't forget to change the function prototype on line 12 too.

sumArray(a, totalSales);

BTW: you should name arrays something other than one-letter names.

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

line 29: open() wants a const char* for the filename and you passed a std::string object. I'm supprised your compiler did not object and spew out some nasty error messages. It should be this: in.open(inFile.c_str()); line 39: unnecessary -- if open() failed the stream can not be closed.

line 73: input file was never opened so lines 73-82 will probably never get executed.

lines 75-80 should not be inside the while loop beginning at line 73 because total sales will get counted several times. Move that for loop outside and below the while loop.

Actually, in sumArray() you don't need that double array at all because you don't do anything with it. A better solution is to read the array into memory once in main() then pass the array to sumArray() function. Just add another parameter to sumArray().

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

endl puts '\n' in the file then causes the output stream to be flushed to disk. The interpretation of '\n' depends on the operating system and whether the output file was opened in text mode or binary mode.

Are you attempting write the file out on *nix operating system then transfer it to a MS-Windows where you read it with Notepad or some other text editor ? That will cause the behavior you described. Otherwise I have never had that problem.

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

check out this site. If you are using ancient Turbo C++ I don't think it can access either PS2 or USB mouse ports because you will need a MS-DOS device driver which pre-dates both port types.

If you are using the newest version of Turbo C++ then you can use win32 api windows program mouse events.