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

what compiler are you using? I tried to compile it with three diffeent compilers and none of them knew about strptime().

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

moved

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

Thread closed.

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

what is the link error?

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

because conio.h is non-standard so not all compilers support it, and some compilers support only some functions. You's use it at your own risk of your program being non-portable to other compilers.

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

why use qsort() ? use the c++ sort() that's in algorithm header file. I don't know if qsort() works with vectors.

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

c++ makes some things more difficult to do. This is one example -- can't just binary write classes that contain other c++ objects/classes. And C-style structures that contain pointers can not be easily written to binary files either.

And I agree with the article in your link -- there are trade-offs to writing binary files.

plus: writes are fast, easy to create random access fixed-length files

minus: impossible to change the format (such as add or remove data elements) without rewriting the entire file.

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

include non-standard conio.h header file.

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

read the file one word at a time and compare each word read with the string. you can use fstream's extract operator >> to do that

std::string word;
std::fstream in("filename");

// read one word
in >> word;
// now compare
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 45 should be like this: (use the value object) outputStream << value.real;

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

here is how that loop should have been coded. Your program has a lot of unnecessary and just plain clumbsy code, such as the way it increments strLineInfo

while(fgets(strLineInfo,256,fpInputFilePtr))
{
      if( strLineInfo[strlen(strLineInfo)-1] == '\n')
                 strLineInfo[strlen(strLineInfo)-1]='\0';
      ptrStrLineInfo = strtok(strLineInfo,strToken);
      while(ptrStrLineInfo != NULL)
      {
              a[nTmpCnt]=atof(ptrStrLineInfo);
              ++nTmpCnt;
              ptrStrLineInfo = strtok(NULL, strTokan);
      }
}

>>memset(strLineInfo,'\0',sizeof(strLineInfo));
Since strLineInfo is a pointer the sizeof operator will always return the size of a pointer, which is 4 on most 32-bit compilers. So that memset line is pretty useless.

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

Hllarious and in the true form of Benny Hill :cheesy: :cheesy: :cheesy:

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

you might be able to get it on DVD or CD for $10.00 or so if you look on M$ site.

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

it doesn't sort because you commented that line out in main(). And what is all that crap at the beginning of every line that you posted? I hope you didn't put that there intentially :eek:

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

sometimes professors make mistakes too.

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

you forgot the void function return type

void selectionSort (vector<int>& list, size_t length)

depending on what compiler you are using you may also have to redefine length as size_t instead of int.

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

you need to pass the vector by reference, not by value. like this: void fillArray(vector<int>& list, int length) [edit] Sorry Joe, I didn't see your post before I posted mine [/edit]

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

The code contains an error -- it accesses an element of the array that does not exist, which probably explains why one of the results is 0 instead of 7.

Anyway, the reason for the strange arrangement of the final results is that the function only sorts part of the array. A complete bubble sort algorithm requires two loops, not one.

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

Yup -- here

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

Add a switch statement after line 44 that will execute the desired action. then put lines 30 to 44 (and code you add in the switch statement) into a do or while loop so that it can be executed more than once.

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

rofl

i disklike c++ myself, but i appreciate its importance

they should make a better c++ and call it D that would be cool

(and yes ive tried c# and c++.net and dislike them also)

They'd have to call it E or something else because there already is a D language. :)

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

google is a good programmer's buddy (normally) Here is a thread I found that will help you.

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

you have to print each field individually

printf("name: %s\n", Doom3.name);
printf("memory: %d\n", Doom3.memory);
...
blas commented: lol... I cant understand this :P +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> i am running this on unix by the way
if both client and server are on the same os (unix) then the problem is something else.

>> how do i change the integer into an ascii cod
c++ example, use stringstream class

#include <sstream>
...
...
stringstream stream;
int n = 123;
stream << n;
cout << stream.str();

c example

#include <stdio.h>
#include <string.h>
...
...
char buffer[80];
int n = 123;
sprintf(buffer,"%d", n);
printf("%s\n", buffer);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>>>i want to binary write a class-struct which contains a string me
you can't write it out all in one write() function call like you can structures that contain char arrays. You will have to write the members of the class individually.

Here is how to write fixed-length strings, but I don't think this is what you are looking for.

#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main()
{
string string1("Hello");
string string2("World");

cout << setw(10) << string1 << setw(10) << string2 << endl;
cin.ignore();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>it doesn't need any interaction from the console

Yes it does if you want to keep the console window from closing. Try what we suggested and you will see why it is needed.

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

Here is one tutorial to get you started. If your intent is to write games then you should probably use one of the graphics engines, such as DirectX SDK which is free for download from Microsoft.

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

very good and unusual :cheesy:

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

can't help you if you don't post your code.

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

If the client is MS-Windows and the server is *nix then you have Big Endian-Little Endian proglem The easiest way I know to correct it is to transfer the data as ascii text then use atol() or similar function on server side to convert back to integer in its own format.

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

yes, lean how to use sockets in your program. Here is a simple tutorial that might get you started.

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

VC closes the console window when the program ends. If you want to see the program's output you have to add something before the return to make the program wait for you to press a key before continuing. calling cin.ignore() just before the return statement will accomplish that.

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

mysql web site has lots of examples and also free MYSQL++ classes.

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

American President John Kennedy was probably the most famous American for his strange dialect (Ted Kennedy is like that too). Example: they pronounce "car" as "ca" (drop the r sound)

Have you noticed that American TV national news people have mid-western accent? That's because its considered the easiest accent to understand. Only local TV newspeople have local accent.

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

>>Sorry, I am not that advanced and do not know how to note if a string is an empty one or not.

a string is empty when any one of these conditions exist.

inputStr == "";

or

inputStr.length() == 0

or
inputStr.size() == 0

as for multiple blank lines -- it doesn't matter how many blank lines there are, just set the flag to true each time a blank line is detected.

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

I was terrible at it -- only guessed 4 correctly. And Joe they did tell me which ones were fake and real (maybe because I did so poorly???)

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

I would use a flag to indicate the end of a paragraph -- the first blank line is the end of the paragraph. When the flag then indent the next non-blank line and reset the flag to false.

The while loop is better written like this

while( getline(inFile,inputStr) )
{
    if ( <flag is set> )
     {
       outFile << "     " << inputStr << endl;
       <set flag to false>
     }
    else
     {
       outFile << inputStr << endl;
       <if inputStr is an empty string set flag to true >
     }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

before reformatting the hard drive and starting all over again try getting a spyware program from the net and see what it finds. Its probably not a virus but may be spyware or some keylogger.

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

When I installed Vista Home Premium upgrade on d: drive it left the XP Pro on c: intact and now I can boot with either os (dual boot)

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

Here is a brief tutorial

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

ya but u need a third party disc as well. lol thats helarious file shrsdding where do u come up with that stuff lol

which is cheaper ? buy a good file recovery program for a couple hundred dollars (or so) or pay an employee to rewrite the whole program that he foolishly failed to back up on another disk ? Rewriting programs can be a very expensive alternative not only in lost programming time but also in delayed program release and possible loss of contracts. A software house could even get sued over failing to deliver on a contract.

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

are you using one of the Windows os ? If so did you check the Recycle Bin to see if the deleted file(s) are there?

Lesson learned: from now on may sure you have copies of important files on another computer, diskette, or cd. backing up files frequently is an important part of the job.

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

windows.h contains all the functions you will need for win32 api programs. If you have used functions in graphics.h, then forget everything you learned because ms-windows programming is completly different.

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

Why use sprintf() in c++?

I agree that stringstream would be better solution than sprintf(), assuming the OP knows how to use it. Its not only a better solution but easier to use too.

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

One way to do it might be to convert the integer to a string to make it easier to manipulate the individual digits. sprintf() function will convert the int to a string.

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

people may want to view your doc file because they can contain viruses.

I only write programs for other people for a fee -- and lots of it. If you want to pay someone to write the program then post in the job offers board.

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

Sorry, Jeg, but your code doesn't work either. The lines (16-21) using strtok() are incorrect and will only find the first occurence of the colon and no others. Please test out your program to make sure it works before attempting to show someone else how to write a program.

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

jdo not use the string.h file that was included in the download -- it probably doesn't work with the Microsoft compiler. Microsoft has its own version of string.h that you should be using. Just delete string.h from your project directory and remove it from solution view.

Second, please do not post so much code, zip it up into a file and attach it to your program.

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

I just compiled it with VC++ 2005 Express and did not get any of those errors. I commented out line 24 because I don't have mygetopt.h and line 38 because I don't have diagnostics(). I added main() and everything else compiled and linked ok. Maybe there is a problem with mygetopt.h ????