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

It will be a lot easier to sort if you put the dates and hights in arrays.

char dates[3][20];
float heighs[3];

The those prompts only have to be coded once inside a loop that counts from 0 to 3.

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

You need to code a sort algorithm -- the easiest to code is the bubble sort. Search google for lots of example programs.

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

That will work providing you create the makefiles for each os as I described previously.

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

The best way to do this would be know what OS your program will be working on. I think if you put the Windows call in a function and set it to return a bool true if successful and false if not (using an if statement) then you would be able to determine if you should call the other function.

\


Not really. If the program is being compiled for *nix then the MS-Windows win32 api functions are not even available to the program, so it is impossible for the program to call it.

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

The program must know what operating system its running under because it has to be recompiled for each os. Add some sort of preprocessor directive that tells the program what os its being compiled for. For example, you might put the define _WIN32 in the makefile when compiled for MS-Windows and _UNIX in another make file when being compiled for *nix os. Inside the program you can use that macro to determine which operating system its being compiled for.

#ifdef _WIN32
// do something for MS-Windows
#elif defined(_UNIX)
// beging compiled for *nix
#edndif
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

We don't do people's homework for them. You write -- we will help. Post what you know how to do then ask questions about the parts you don't know how to do.

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

class Bicicleta must implement all pure virtual methods of its base class before it can be instiantiated. It does not do that, hence the error message. Add the function virtual float calcImposto() const; (identical to the one in Veiculo but without the =0 part) to Biciclets and it should resolve the problem.

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

search: open the file for reading then read each record until you get to the one you want.

delete: you have to rewrite the entire file. Open the original file for reading, open another temp file for writing. Read a record, if not the record to be deleted write it back to temp file. Do that for all records. When done, close both files, delete the original, then rename temp to the name of the original.

edit: very similar to search. After locating the record allow the user to make changes. Then do something similar to delete described above except replace the original record with the new one.

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

To be considered what?

Ezzaral commented: My exact thought :) +12
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

My understanding is the range of a float is +/- 3.4e+/-38, with 7 digits precision. The number above would comfortably fit in that range.

The value in question is outside that range (-5 is smaller than -3), which is why I can't be stored in a float without data truncation. Some compilers, such as VC++ 2008 Express, will produce truncation warnings when attempting to store -5.9875e17 in a float.

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

>>meanwhile the main problem is finding out how to include the header file

But the code you posted does it correctly #include <iostream> is all that is needed. The the compiler starts reading your program the #include statement causes it to open up the include file and add its contents to the *.cpp file that is being compiled. That is part of the preprocessor operations.

You are probably getting compile error messages on pen.h because you forgot to add using namespace std; after including <string> or you can use std::string Brand; to declare the namespace.

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

what compiler and operating system?

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

yes. You shouldn't use dynamic allocation unless its really needed. Depends on the context of the rest of your program.

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

lines 72, 79 and 127. constructors can't be called directly like that. You have to instantiate an object of type Month in order to call the constructor. One way to fix the problem is to create a set function.

class Month
{
 public:
    ...
    void set(int month)
    {
         if(month > 0 && month <= 12)
             this->month = month;
     }
     ...
}

Now your program can call SetMonth() whenever it needs to instead of calling the class constructor.

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

What you posted looks ok, so the problem is after that while loop. If its prompting for more user input, such as a string, then you have to clear the input stream of the '\n' that's still in the input buffer from inputting an integer. See this thread for how to do that.

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

It seems to me that's a pretty serious flaw. I wouldn't touch Chrome until after it comes out of beta because its hard telling what else it might do to my computer.

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

From the original post

int main (void)
{
    float a;

    int n;

    printf("\n enter values of a an n");

    printf("\n %.4f to the power of % d is %.4f",a,n,power(a,n)); 
}

What's the value of n ? Answer: It just has some random value because it was never initialized to anything. You forgot to get user input using scanf() or something else.

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

Actually, that is a list, not a vector. Minor differences, but still.
Here's one way (matrix of strings):

typedef vector<string> row;

vector<row> *vec1 = new vector<row>;

That's not managed code, but managed code is probably something similar.

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

Call it twice. The first time pass 0 for pSecurityDescriptor and nLength parameters -- The function will fill in the required length in the pnLengthNeeded parameter. You can then use that value to allocate buffer and call the function again.

Or you can just simply allocate a buffer large enough to hold the description -- no harm done if its larger than needed.

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

well im doing a phd in physics and i am a chemist so im in as good a position to understand it as you...

Not true -- you are in a much better position to understand it because you probably have the math background. And I wish you well on getting your phd.

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

When doing the swap you have to swap the entire structure, not just the score. The name has to be swapped along with the score.

line 77 makes no sense -- you are comparing non-existant array elements because I assume parameter n is the number of structures in the array, which counts from 0 to (not including) n.

For small values of n I suggest using the bubble sort, because its the easiest to code. You will find lots of examples on the net.

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

>>but I dunno if its allowed here.
We won't have a problem with it. But think -- do you want other students and your teachers finding that code here on the net ? Don't post it unless you are sure you and your school are ok with that.

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

"convolute a gaussian". I looked up the word convolute in wiki, and for computer science you need a Ph.D. in math in order to understand it. Well, I barly passed 1st grade math :)

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

you could start here

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

>>How can I use this for copying strings to each other instead?
You don't need strcpy() to copy one std::string to another. Just simple assignment operator = will do the trick

std::string s1 = "Hello World";
std::string s2 = s1;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Number 7 has two correct answers
No -- 5.9875e17 can only be stored in a double -- floats are too small.

VernonDozier commented: Good catch. +7
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) yes, 2. just means 2.0

2) That is just a shorthand if-else statement. You have to be careful with that because occasionally I've found that it doesn't work correctly.

if( K-Sp) > 0)
    aux += K-SP;
else
    aux += 0;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The code I posted assumes three items on a line (a string and two integers). On every loop iteration fstream will read an entire line then go on to the next line, and keeps doing that until end-of-file is reached. If you are having problems grasping that concept then put a print statement inside the loop and run the code so that you can visually see what it is doing.

Its not possible to just skip lines -- the file has to be read sequentially from beginning to end.

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

You didn't read the code I posted did you ????? It contains a couple of lines that strips those '\n' from the middle of the lines. Go back and study that code again.

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

Post code because I can't see your monitor or what you did. The code I posted works ok with the test data you posted.

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

If this is a C program then do not code it in a file with *.cpp extension because the compiler may give some wrong error messages. Rename the file to have *.c extension for better compile messages.

line 7: it should be int main() -- you can not leave off the function's return type

compare the differences between lines 4 and 17. They must both have the same parameters.

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

>>write << "\ncirculo # " << (i+1) << ": " << array[pos]+array[size-pos-1];

Variable pos is never changed. I think you should use the loop counter instead of pos.

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

That while loop is incorrect -- you don't need to use eof()

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

int main ()
{
fstream write;
int a = 0;
write.open ("RSO.txt", ios :: out);
string line1;
string line2;

ifstream myfile1 ("RS.txt");
ifstream myfile2 ("YULIA.txt");

if (myfile1.is_open())
{
    while ( getline (myfile1,line1) )
    {
                myfile2.seekp(0, ios::beg); // back to beginning of file
                myfile2.clear();
                while (getline (myfile2,line2) )
                {
                      if (line1 == line2)
                      {
                          write << line1 << endl;
                          break; // stop looking
                       } 
                 }
              }
          }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

fstream will skip white space for you -- you don't have to do a thing

ifstream in("filename");
string word;
int val1, val2;
while( in >> word >> val1 >> val2)
{
    // do something with these values
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use fstream's >> operator to read just one word at a time.

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

The answers to three questions are just flat out wrong

4. Which line has all reserved words ?
if, else, for, while do, switch, continue, break

while do is not a reserved word.

8. Select the correct definition for a string variable.

Both 1 and 4 are correct answers.

11. Select the correct function definition (NOT prototype) from the list below.

double pow(double num, int pow); is wrong because its a function prototype

13. Write a for loop that counts from 0 to 5.

for (c = 0; c <= 5; c++) that counts from 0 to 6, not 0 to 5.

14. What does the statement #include do ?

All answers are wrong.

And the most outregous question of all

15. Which of the following converts an integer "value" to its ASCII equivalent ?

atoi() does just the opposite of what they say it does.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
std::string line;
        ifstream in("filename");
        while(getline(in,line,'.') )
        {
            size_t pos;
            // remove embedded line feeds if they exist
            while( (pos = line.find('\n')) != string::npos)
                line.erase(pos,pos);
            cout << line << ".\n";
        }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The first error on line 84 means that you are trying to treat hiscore.score as if it were a simple integer -- it isn't because its an array. My suggestion is to make it a simple integer. Do you really need it to be an array?

struct highscore
{
	string name;
	int score;
};

If you really do need that to be an array, then you will probably have to write another function to search it for hightest score so that it can be added on line 84.

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

you don't need dato and dato2 because the code you posted does nothing with them. You could modify the code I posted like this:

int pos = 0;
while( read >> array[pos]  >> array[size-pos-1])
{
   pos++;
   largo += 2; // how many elements are in the file
}
// now that you have all the numbers in an array, just add them
// up the way you want them
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

if you are getting multiple definition errors, change your headers to look like this:

#ifndef HEADERNAME_H
#define HEADERNAME_H

// Your code here

#endif

That way if you include a header more than once, it'll only be included if it hasn't been.

Read previous responses -- that isn't the problem.

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

No it doesn't matter because the second parameter to FindEventR() is not a member of any class.

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

http://helpobamasbrother.org/

So what? Barack Obama had nothing to do with where his siblings were born. Its very possible Barack wants nothing to do with those people. As for that link, maybe George doesn't want any help -- he may be perfectly happy where he is.

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

The problem is that you defined ListNode as a private member of Event class. So you can't use that structure outside ListNode. Make the structure public or move it outside any class. If you leave it as public member of Event class then you have to use Event::ListNode in order to access/reference it.

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

Read the Read Me threads at the top of this c++ board. They contain lots of information.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
#include <windows.h>
#include <iostream>
#include <string>
using std::cout;
using std::string;

DWORD ShowError()
{
    DWORD dwErr = GetLastError();
    char buf[255] = {0};
    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0, dwErr, 0, buf, sizeof(buf), 0);
    cout << buf << "\n";
    return dwErr;
}

string GetFileOwner(string szfilename)
{
    BOOL bSuccess;       //' Status variable
    DWORD sizeSD;         //' Buffer size to store Owner's SID
    PSID pOwner = 0;         //' Pointer to the Owner's SID
    char ownerName[255] = {0};    //' Name of the file owner
    char domain_name[255] = {0};  //' Name of the first domain for the owner
    DWORD name_len;       //' Required length for the owner name
    DWORD domain_len;     //' Required length for the domain name
    DWORD nLength;        //' Length of the Windows Directory
    SID_NAME_USE deUse;          //' Pointer to a SID_NAME_USE enumerated type 
                         //   ' indicating the type of the account
    char sdBuf[255];
    BOOL OwnerDefaulted = 0;
   //' Call GetFileSecurity the first time to obtain the size of the buffer
    //' required for the Security Descriptor.
    bSuccess = GetFileSecurity(szfilename.c_str(), 
                OWNER_SECURITY_INFORMATION, &sdBuf, sizeof(sdBuf), &sizeSD);
    //' exit if any error
    if(bSuccess == 0)
    {
        ShowError();
        return "";
    }
    
    //' Obtain the owner's SID from the Security Descriptor, exit if error
    bSuccess = GetSecurityDescriptorOwner(sdBuf, &pOwner, &OwnerDefaulted);
    if( bSuccess == 0) return "";

    //' Retrieve the name of the account and the name of the first domain on 
    //' which this SID is found.  Passes in the Owner's SID obtained previously.  
    name_len = sizeof(ownerName);
    domain_len = sizeof(domain_name);
    bSuccess = LookupAccountSid(NULL, pOwner, ownerName, &name_len,
        domain_name, &domain_len, &deUse);
    if( bSuccess == 0) 
    {
        ShowError();
        ownerName[0] = …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I suspect you completely missed the whole point of that video. He (Manning?) said the press should leave Bristal out of her mother's politics. If the press is going to talk about Bristol Palin then they have to talk about everyone else's family black sheep, who also have nothing to do with anyone's political goals. And I wholeheartedly agree with that statement.

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

Here is an example in VB, which you should be able to translate to c++ because they both use the same win32 api functions.

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

You probably can't use HeapAlloc() to allocate memory for pThreadRecvData because std::list allocated memory from the standard heap using new operator. Replace HeapAlloc() with new and retest.

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

Oh you should have listened to the whole thing! He made a lot of sense (to me) -- if the news media wants to dig up the dirt on Sara Palin's daughter and post it all over the net then that opens the can of worms to dig up the dirt about anyone, political or not. I liked the premise of his speech.

He is right about HO's mother -- she was white trash. But we can't blame HO for the sins of his parents.

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

Same thing ArkM told you a half hour ago.

The problem is that you are including readcharacter.cpp in main.cpp as if readcharacter.cpp were a header file. Never ever do that. Each *.cpp file must be compiled as if it were the only *.cpp file in the project. After the files are compiled, the compiler will link them all together.

What you need to do is remove that line #include "readcharacter.cpp" from main.cpp. After that the whole think links correctly. That doesn't mean the program is bug free -- it only means the compiler successfully compiled and linked it.