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

depends on the operating system. QT is portable between operating systems. And for MS-Windows you could start with this win32 api tutorial

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

Turn it ON, stupid.

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

Unlikely James. Those who came back from Vietnam with half a skull missing usually also had half their brain missing due to heroine and pot use, so there was no need for the missing half to put the rest back in ;)

can't blame those docs for having to do their work on dopeheads, I agree.

Don't knock it unless you have walked in their shoes. Seeing the horrors of war has got to drive anyone to drink and/or drug use. Soldiers coming back from Iraq are also having lots of mental problems from their experiences.

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

>>Sorry, I can't post the code.
Sorry, my crystle ball is broken too.

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

>> Stack around the variable buf was corrupted
That means the program has trashed the stack somewhere. That's a tough one to find. Check for buffer overruns, writing beyond the end of a buffer or array, using uninitialized pointers, and indexing into non-existant array elements. If you still can't find it then start commenting out blocks of code until the problem disappears. When that happens you have probably found the deamon.

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

What I mean is to change "..\bin" to "c:\Dev-C++\bin" You have to do that in each of those directory categories shown in the combo box.

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

Anyone have a crystle ball I can borrow? I lost mine somewhere.

Also, that seems to be a C program, not c++.

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

That zip does not include everything needed to compile and link the program. I need ALL the source files including all the *.c and *.h files in the project.

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

Video here

I'm not having a problem with any of the links I posted. They work ok for me.

The changes for Dev-C++ are just directory settings. Go to menu Tools --> Compiler Options. In there change the relative paths to full paths in each of the tabs.

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

line 32: add a print statement after that to see if it read the numbers correctly. Doubles use "%f" instead of "%d" so the format string is incorrect.

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

If you can get to this page scroll down to the bottom of the page and click the Introduction to Visual C++ Video" link.

Regarding Dev-C++. What version of MS-Windows are you using ? It has a vew problems with Vista that you need to correct in the compile options.

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

lets say you want an array that can hold up to 10 divisors. Then you would declare it like this: In addition to declaring the array the code below will initialize all elements with 0. int divisors[10] = {0}; Each of the elements of the array are numbered 0, 1, 2, 3, ... 9. Note that the first element is numbered 0, and not 1. And the last is numbered 9 instead of 10.

How lets say you want to find all the divisors of the number 100. The first divisor will be stored in divisors[0] the next divisor in divisors[1], etc.

A divisor is one in which 100 divided by some number (called the divisor) does not have a remainder. So 100 % 2 == 0 means that 100 is evenly divisible by 2 because it does not have a remainder. Therefore 2 is a divisor and should be inserted into the array.

You will want to create a simple loop that counts from 1 to 100 and check each value of the loop counter to see if it is a divisor of 100 (in the above example).

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

you should first create an empty project then copy the source files that you have into the project directory and finally add the files to the project. If you are using VC++ 2008 Express: read and watch this tutorial

If you really have zero knowledge of C language then I'd suggest you take a look at some online tutorials or read a book. There are many suggestions in the Read Me threads at the top of the C++ board.

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

>> ideas ?

Yes, here is one solution

int main()
{
    char line[] = "333 hou 23se 444 bi 4g";
    char buf[100] = {0};
    char *p1 = line;
    char *p2 = buf;
    while( *p1 )
    {
        // use temp pointer to locate
        // end of digits
        char* p3 = p1;
        while( isdigit(*p3) )
            p3++;
        // is there a space following the digits ?
        if( *p3 == ' ')
            // yes, then skip the space and move on to the next char
            p1 = p3+1;
        else
        {
            // no, then was the last char put into temp buffer
            // a space
            if( *(p2-1) == ' ')
                // yes, then overwrite that space with a new character
                p2--;
            p1 = p3;
        }
        // copy all characters up to the next digit
        while(*p1 && !isdigit(*p1) )
            *p2++ = *p1++;
    }

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

lines 18 and 19. Why do you want to overwrite the last character read by '\n'? Don't you want to append it to the end of the string instead of overwriting the last character ? Actually I don't know why you want to do that anyway -- we normally just delete the '\n' if it exists.

line 20: useless line. record is already the full line that was read from the file. There is no reason to call strtok() for that.

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

>>while (a != 'A' || 'B' || 'C')

wrong way to code that while (a != 'A' && a != 'B' && a != 'C') or this while( a < 'A' || a > 'C')

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

>>I have done like this.. but still many error..
So, fix the errors. After all this time you should know how to recognize the errors and correct them.

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

The problem is in some code before those functions. Most likely you forgot the function's closing brace }. That makes the compiler think that the next function is being nested inside the previous function. Count the braces and make sure there is a } for every {.

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

Here is an example of reading integers from a file

int a,b,c,d;
FILE* fp = fopen("filename.txt","r");
if( fp != NULL)
{
    fscanf(fp, "%d", &a);
    fscanf(fp, "%d", &b);
    fscanf(fp, "%d", &c);
    fscanf(fp, "%d", &d);

   // you can also compress the above into just one line
   fscanf(fp,"%d %d %d %d", &a, &b, &c, &d);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

In the US, if a person gets sick, goes to the hospital and then can't pay the bill, the rest of the hospital users pay for it in inflated bills. Let's face it, just a goofy type of 'take from the wealthier to pay the poorer' socialism.

Well, it doesn't work quite that way in my state (Illinois). Hospitals can not turn anyone away, that much is true. But all they are required to do is supply life-threatening medical services. Once past that, out the door they go.

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

I think im just going to go with the real pic of myself as a personal touch.

Yea, that mugshot fits your name also :)

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

line 68: >> float AverageGrade(Student[], int nStudents)
You have to give Student array a name before you can use it, for example: float AverageGrade(Student students[], int nStudents) you had that function almost right in your post #7. Why did you decide to delete all that code? All you had to do was add a return statement at the end of the function.

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

Its a lot simplier in c++

ifstream in("myfile");
int n;
in >> n;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>oh yes, make this country safe without having to kill everyone else ...
That's a big problem, because we can't control what other countries do, unless of course we invade and destroy a sovern nation like Bush did. The primary job of the federal government is the security of this nation, not giving free medicane etc to everyone who wants it.

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

>>I don't quite know "what to return" from this block of code
It means that function must return something. You need to add return input; on line 29 or the first code you posted.

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

>>It's in the government's interest to scare the public, so they can spend more on the military.

Spending more on military is GOOD for the economy, it gives people jobs. Someone has to make all those cloths, bullets, tanks, etc. etc. I don't think we get much of that from China or Japan. So does your statement mean you don't want people to have jobs ?

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

is n an array? NO SO YOU CAN'T USE n

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

>>Is there a way that will check that the user login belongs to which row in my text file
probably, but it would be os dependent. Get the user's loging name using some system function call and then compare that with the user name on each line of the file. I have no idea how to get the login user name in *nix.

>> string u(line,0,found);
I don't think that works. What you want is this: string u = line.substr(0,found);

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

look at line 78, now look at line 72. Don't you see something a little strange about line 78 :)

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

Huh?

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

>>how do I concantinate the filename?
strcat(FilePath,"Filename");

or

strcat(FilePath,"\\Filename");

depending on if getcwd() terminates the path with '\' or not.

CodeBoy101 commented: Perfect!! +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Not directly, you have to read the file one line at a time until you find marry's row. When working with files with variable-length rows there is no easy way to do it.

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

Narue: I liked the other one better That lady holding the chainsaw and wearing Jason's mask just did something for you. :)

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

If those are two different problems then please start a new thread for each problem. Tossing them all together into the same thread makes it almost impossible for others to answer without a lot of confusion

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

can you please show me how to do one of the two PLEASE?

Sure -- here is the first line

for(int i = 0; i < 15; i++) // number of spaces to display
  cout << ' '; // display one space
cout << '*';  // finally display the asterisk

you can also do it using C functions

char line[126];
sprintf(line,"%15.15s", "*");
cout << line;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

jamthwee is right -- in order to change something in a text file you have to rewrite the entire file, making whatever changes you want while writing the file. Calling seekg() does nothing to help you with that. If the current password is "abc" and the new password is "abcdefg" then you can't stuff 7 characters into the filespace for 3 characters.

There are at least two ways to do it:
1) read each line of the file into an array of lines, make in-memory change to marry's password, truncate the original file to 0 length, then finally rewrite all the lines back to the file.

2) create a new temp file -- then do this pseudocode

open original file for read
open new temp file for write
while not end of original file
    read a line from original file
    is it marry's line?
    yes, then make change to password
    write line to new temp file
end of while
close both files
delete original file
rename temp file to original file name
done

[edit]If the new password is exactly the same length as the password in the file, then open the file for read/write, seek to the position of the old password then just write in the new password.[/edit]

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

To do the second one just print spaces before the stars.

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

>>2-4 are just reflections/rotations of the first one
That tells us nothing.

>>please help with the other 2
And you can't count either because 4 - 1 != 2 :)

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

It's a bit like how to read a file, but you're going to read the windows registry. First you have to call RegOpenKey() to get a handle to the registry key entry, and then RegQueryValueEx() to acaully read the key entry, finally RegCloseKey(). You can find all those functions, and others too, from here

If you want examples, then just use google and you will find lots of them.

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

char* is a pointer which can be made to point to most anything, while I guess you mean std::string c++ class.

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

you need to keep two different pointers for curr because you have two different loops. Try this:

curr1 = head;
  while(curr1)
    {
      strcpy(check,curr1->word);
      curr2 = curr1->next;
      while(curr2)
        {
          if(strcmp(check,curr2->word)==0)
            printf("duplicate"); {here should come the remove node function}
          curr2 = curr2->next;
        }
        cur1 = cur1->next;
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>stat = canWrite(hnd, 1234, size, 8, canMSG_EXT);
what is the 1234 and 8 for? sizeof(size_t), which is an unsigned int, if 4 on most 32-bit computers, not 8.

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

Q1: do you know what 2! and 4! mean and how to calculate them with pencil & paper? If not then you need to study factorials, which are used in statistics.

Q3: do it just like you would numbers. Lets say you have three characters 'C', 'A' and 'Z'. Which one is the least and which is the largest. If you still don't know then look up their ascii values in any ascii chart.

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

There have been many new advances in artifical limb technology since 9/11 published in both the USA and UK medical journals. The Bionic Man and Woman will be a reality in the new future. Just hope its not a huge flop like the Bionic Woman TV series this year -- yuuk!

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

If you use getline() instead of get() you don't have to call ignore()

int main()
{
    char getdata;
    cout << "Enter one character: ";
    cin >> getdata;
    cin.get();
    
    char line[20] = {0};
    cout << "\nEnter a line of text 20 characters max: ";
    cin.getline(line,20);
    cout << "\nLine of text entered : " << line << "\n";
    //cin.ignore();
    
    char line2[20] = {0};
    cout << "\nEnter another line of text 20 characters max: ";
    cin.getline(line2,20);
    //cin.ignore();
    cout << "\nSecond line of text entered : " << line2 << "\n";

    cout << "\n\nNow at the end of the program";
    cout << "\nFirst character of line[20] " << (int)line[0] << endl;
    cout << "First character of line2[20] : " << (int)line2[0] << endl;
    
    if (cin.eof())
        cout << "\ncin.eof() = true";
    else
        cout << "\ncin.eof() = false";
    if (cin.fail())
        cout << "\ncin.fail() = true";
    else
        cout << "\ncin.fail() = false";
    
    // exit routine
    cin.clear();
    while (cin.get() != '\n')
        continue;
    cin.get();
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

try this slightly modified version of your program. In both cases you can only enter 19 characters, not 20, because the 20th byte is reserved for the string's null teriminator -- 0.

int main()
{
    char getdata;
    cout << "Enter one character: ";
    cin >> getdata;
    cin.get();
    
    char line[20] = {0};
    cout << "\nEnter a line of text 20 characters max: ";
    cin.get(line,20);
    cout << "\nLine of text entered : " << line << "\n";
    cin.ignore();
    
    char line2[20] = {0};
    cout << "\nEnter another line of text 20 characters max: ";
    cin.get(line2,20);
    cin.ignore();
    cout << "\nSecond line of text entered : " << line2 << "\n";

    cout << "\n\nNow at the end of the program";
    cout << "\nFirst character of line[20] " << (int)line[0] << endl;
    cout << "First character of line2[20] : " << (int)line2[0] << endl;
    
    if (cin.eof())
        cout << "\ncin.eof() = true";
    else
        cout << "\ncin.eof() = false";
    if (cin.fail())
        cout << "\ncin.fail() = true";
    else
        cout << "\ncin.fail() = false";
    
    // exit routine
    cin.clear();
    while (cin.get() != '\n')
        continue;
    cin.get();
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>1>c:\users\cvarner\desktop\assignment10\assignment10\file1.cpp(62) : error C2664: 'Student::SetNID' : cannot convert parameter 1 from 'float *' to 'char []'

That means you are attempting to pass a float to a function that is expecting a character array. Look at the class for method SetNID and then look at the parameter it expects. Either change the parameter type or change the data type that you are trying to send it.

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

That leads me to think that the program is not running in the same shall as you were when you tested echo $HISTFILE from the command line.

I don't remember how to run a program in the same shell. *nix is not my os and its been several years since I've used it.

c++noobie commented: Ancient Dragon was very helpful +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 11: make input a char* char* input std::string crashes when attempting to assign it a NULL

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

post code exactly as you tried to compile it.