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

Sometime newline ends with ^M .

Its not a matter of "sometimes". It either does, or it doesn't, depending on the operating system.
'\n' translates into whatever the operating system uses as end-of-line. MS-Windows: "\r\n". *nix: "\r". Not sure what MAC uses.

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

>>So if i were to print an my array of names, say for a roster of passengers on an airplane would this code be correct?

Did you run that code? Did it work the way you wanted it to? Answer those two questions "YES" and you will have the answer to your question.

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

The very first error message should have told you that AVLNode is undefined

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

what you need is an array of strings so that the program can keep all the strings until ready to print them all out

const int MAXSTRINGS = 10; // hold max of 10 strings
const int MAXLENGTH = 25; // maximum of 40 characters per string
char firstname[MAXSTRINGS][MAXLENGTH];
char lastname[MAXSTRINGS][MAXLENGTH];

how you will have to index into those arrays

int i;
for(i = 0; i < MAXSTRINGS; i++)
{
    printf("Enter a first name\n");
    fgets( firstname[i], MAXLENGTH, stdin);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 59: why are you attempting to so math on std::string objects? test1 and test2 are std::strings, you can't divide them by 2 then multiply them by 2 like that line is attempting to do.

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

try this: the compare function isn't needed.

string junk;
      string junk1 = "cls";
      while( inFile >> junk  && junk != junk1)
             ;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Vegetarian friends tell me that the smell of frying bacon is one of the worst temptations that they face....

That smell doesn't bother me in the least -- my wife cooks it each morning for her breakfast, but I eat something else, normally dry cereal with soy milk. This morning I had SOS (commonly called Shit On A Shingle), or biscuits and beef gravy.

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

I think it would be easier to validate user input by getting it as a string then validating the string. For example, if I type "122abv234", scanf() will only pick up the first three characters and ignore the rest with no warning. But if you validate that as an array of characters your program can easily detect that it contains invalid characters.

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

Must be a coincidence. I went back and purposely missed every question. Got zero percent, as I expected I should.

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

Welcome to DaniWeb. See our Project Partners Wanted forum

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

The do loop is incorrect. See correction below. Same problem with getMinutes().

void getHours (int& input1, string& s)
{
	bool result;
	do {
	cout << s;
	cin >> input1;
	result = isValidHours(input1);
	} while (result == false);
}
anbuninja commented: b/c you always help me out :D +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>printf("%s %s %d %d\n", coltitle[0], coltitle[1], table[k][0], table[k][1]);

coltitle is just an array of one character, not an array of strings. It was declared as char coltitle[2]; "%s" tells printf() that the next argument is a null-terminated string. But what you sent it was just a single character -- coltitle[0].

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

So, I think evolution is a basic fact of existence, and, if it is presented properly as such, it does not conflict with a belief in a Creator, whether you call that creator God, Yahweh, Allah, or by anyother name. I think that it really hammers home the awesome wisdom of this Creator or First Cause.

I tend to agree with that, but creationists do not. A true creationist believes God created everything as they appear today -- no evolution involed in the process. They believe in the literal interpretation of the first few verses in Genesis, that the earth and everything on it were created in just 6 earth days. Well, I suppose since God can do anything He could have done things like that, but I doubt that He did. And the scientific studies over the past couple centuries or so have shown that too. Also logic dictates that the earth could not have possibly cooled enough in just 1 day to support life as we know it. In the beginning the earth was just molten lava, very hostil to life. It would have taken several million years to support life.

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

. What "Four yards worth" means is: four yards of; so, to give 'yards' the possessive apostrophe would, I feel be incorrect.

My thought exactly :) In this phrase "Four yards of concrete" there should not be an apostrophe because yards does not possess anything but just describes how much concrete. That statement isn't at all like "my brother's house".

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

Just use two arrays and print both at the same time

char names[20][80]; // array of characters
int scores[20];

// put this line in a loop.  You can put as many arguments to printf() as you want.
fprintf("%-20s %-10d\n", names[i], scores[i];
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you have two objects with the same name. You can only overload functions, not data objects.

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

Speaking of the Big Bang -- where did that huge gas ball come from anyway? What was there before the BB ? Don't you think we humans are just too ignorant to understand all that yet? Even if God did explain it exactly to us it would have the same affect as us trying to explain TV to Julius Ceasar or even worse to Moses.

Rashakil Fol commented: The big bang wasn't a gas ball. -2
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I compiled it with VC++ 2008 Express on Vista Home and got the below output. Didn't get the error you reported.

In gallons/min, what is the flow rate: 1
In inches, what is the diameter of your pipe: 2
What material is your pipe made of? The materials are organized as: 1 for Concre
te, 2 for Copper, 3 for Steel, 4 for PVC, 5 for Cast iron
Please enter the appropriate number (only integer values from 1 to 5 are accepte
d):
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The problem is more than likely dlls. Check your compiler's installation directory to see if it has the DLLs that you need to install on other computers. Also make sure you compile your program for release mode and not debug.

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

It didn't work because you failed to follow the example I posted. Notice I did NOT use eof() because it doesn't work the way you think it works.

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

You first have to declare variables to hold each of the numbers. Then just use the stream's >> operator to read from the file into the number

int SalespersonID, ModelCode, Count, Sold;
ifstream in("filename.txt");
while( in >> SalespersonID, >> ModelCode >> Count >> Sold)
{
    // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

post the input file. You probably don't need those ignore() lines, unless there is other text on each of the lines after the number. The >> operator will ignore all spaces and the '\n' line terminating character(s).

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

scroll all the way down to the bottom of the DaniWeb page and you will see a link to all of them. Its in the grey area named "Newsletter Archive".

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

Quick Question.

How often does the newsletter come out?

Cohen

monthly

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

Welcome to DaniWeb, Chris. Hope you have a lot of fun here, learn a few things, and hopefully be able to help others.

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

I just saw these interesting new articles on nother of my favorite sites and thought I'd share.

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

You can't, and we normally don't either unless it villates one or more of the DaniWeb Rules.

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

>>my problem is to convert the 32 bit float data to integer format

Simple -- just assign float to int

double n = 123.456;
int x = (int)n;
if( modf(n,0) > 0.5
   x++;

Now just send system2 the value of x.

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

Please stop calling us "boss". We aren't your boss.

To initialize the array to zeros: double qty[10] = {0.0}; But qty shouldn't be an array of ints instead of doubles, or are you allowed to buy fractions of sojmething?

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

So what is the problem you are having? To get the average just add them up and divide by the number of grades -- 4th grade math.

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

Yes, ODBC is the oldest and most widely used method, but not the fasted. There are a few free ODBC C++ classes out there too that will help simplify the job-- just google for them.

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

alright i did that still get the same errors

cannot convert parameter 2 from const char to string

Your function prototype is correct now. Next you need to realize that you can not pass a string literal to those functions because the functions expect a reference to a std::string object.

There are a couple ways to fix that:
1) remove the reference operator from the function prototype and the actual function. I see no reason to pass the string by reference anyway. But I understand your instructor wants it that way, so maybe that is not an option for you.

2) Typecase the string leterals

getHours(hours, "Enter the number of hours for the starting time: ");
    getMinutes(minutes, (string)("Enter the number of minutes for the starting time"));

3) split the string literals out

std::string prompt;
prompt = Enter the number of minutes for the starting time.";
getMinutes(minutes, prompt);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What you just posted is incorrect. You can not have the name of a parameter the same as the name of the function. You will get a compiler error on that.


Look at line 5 of the code you originally posted. Notice the two parameters are an int and a string. Now look at the parameters in on line 30 -- the parameters are a reference to an int, and a reference to a string. Change the function prototype on line 5 to look like the function header located on line 30. All you have to do is copy from line 30 and paste on line 5.

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

You could use malloc() and realloc() to allocate space for the array. One way to do it is to allocate one row in the array each time a new line is read from the file. But that is slow and inefficient. I prefer to allocate a block of rows and when they get filled up inreeast the array by another block of rows.

char** array = 0; // 2d array of strings
int arraysize = 0; // current number of rows in the array
int elmsused = 0; // number of rows actually used
const int BLOCKSIZE = 10;

string line;
ifstream in("file.txt");
while( getline(in, line) )
{
      if( elmsused == arraysize)
      {
             array = (char **)realloc(array, arraysize+BLOCKSIZE);
             arraysize += BLOCKSIZE);
      }
      array[elmsused] = (char *)malloc(line.size()+1);
      strcpy(array[elmsused], line.c_str());
      elmsused++;
}

}

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

There is only one thread. The thread is used to continually run and to update the window in the main() section of the program. Also making hWndCurrentTime global does not work either. It actually still shows as undefined when running the thread.

>> hThread = CreateThread(NULL, 0, ThreadTime, NULL, 0, &dummy);

Nope, your program has two threads. The thread with winMain() is a thread and ThreadTime() is the second thread. Every windows program has at least one thread.

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

If you are not allowed to use vector then you will have to read the entire file, counting the line numbers as the loop progresses. There is no other way to do it.

Why do you need the line count? Maybe there are alternative ways to achieve what you want to do.

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

It has been my experience that windows can only be updated in the thread in which they are created. What I have done to resolve your problem is for thread2 to send a message to thread1 so that the window can be updated by thread1. See PostThreadMessage()

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

what is that program supposed to do?

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

Are you in school, is this homework? If yes, then read your textbook and you should find the answers yourself.

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

It does not caluse a memory leak, but both pointers are invalidated after the free.

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

After making that adjustment you have to call mktime() to normalize the structure. Otherwise, I don't know what you mean, so post latest code.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
// line 286:
void DelRec(Passport pass[NUM],int pptNo)//definition of modifyRecord
{	
for(int i=pptNo;i<NUM;i++)	{

pptNo is supposed to be the passport number of the record to be deleted. Right? If yes, then why is the for loop initializing variable i to pptNo? If you look at the addRec() function you will see that the passport number can be almost anything, so its not the index value into the array. To delete the record you need to search the entire array for the passport number, then when and if found delete it.

for(int i = 0; i < NUM; i++)
{
    if( pass[i].pptNo == pptNo)
    {
           // found -- delete this record
    }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

do you mean something like system("cd .."); ?

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

The prototypes do not match the actual functions. Compare them and you will see what's wrong. After that you should realize that you can't pass string literals as you did to those functions -- must pass a reference to std::string object.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
<form method='post' onsubmit='javascript: validateform(this);'>

Testing ... testing

Yup -- its broke all right. I deleted the <b></b> from the original post and its back again.

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

MAX is not a function -- it is a macro. The macro says if a is greater than b then return a otherwise return b.

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

Side question: Do you have to pay for mods, or are there some for free?

We are all unpaid volunteers, which is one reason to have quite a few mods located all around the world for 24/7 coverage.

John A commented: Not those kind of mods. -3
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Can you please suggest me a way to remove this error?
Don't do that.

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

All you have to do is put that code in a loop. Simple.

for(i = 0; i < 10; i++)
{
if( score[i]>79 && score[i]<101 ) {
  cout<<i+1<<"\t"<<score[i]<<"\t\tA"<<endl;
  outfile<<i+1<<"\t"<<score[i]<<"\t\tA"<<endl;
} else if( score[i]>74 && score[i]<80) {
  cout<<i+1<<"\t"<<score[i]<<"\t\tA-"<<endl;
  outfile<<i+1<<"\t"<<score[i]<<"\t\tA-"<<endl;
} else if (score[i]>69 && score[i]<75) {
  cout<<i+1<<"\t"<<score[i]<<"\t\tB+"<<endl;
  outfile<<i+1<<"\t"<<score[i]<<"\t\tB+"<<endl;
} else if( score[i]>64 && score[i]<70) {
  cout<<i+1<<"\t"<<score[i]<<"\t\tB"<<endl;
  outfile<<i+1<<"\t"<<score[i]<<"\t\tB"<<endl;
} else if (score[i]>59 && score[i]<65) {
  cout<<i+1<<"\t"<<score[i]<<"\t\tB-"<<endl;
  outfile<<i+1<<"\t"<<score[i]<<"\t\tB-"<<endl;
} else if( score[i]>54 && score[i]<60) {
  cout<<i+1<<"\t"<<score[i]<<"\t\tC+"<<endl;
  outfile<<i+1<<"\t"<<score[i]<<"\t\tC+"<<endl;
} else if (score[i]>49 && score[i]<55) {
  cout<<i+1<<"\t"<<score[i]<<"\t\tC"<<endl;
  outfile<<i+1<<"\t"<<score[i]<<"\t\tC"<<endl;
} else if( score[i]>44 && score[i]<50) {
  cout<<i+1<<"\t"<<score[i]<<"\t\tC-"<<endl;
  outfile<<i+1<<"\t"<<score[i]<<"\t\tC-"<<endl;
} else if (score[i]>39 && score[i]<45) {
  cout<<i+1<<"\t"<<score[i]<<"\t\tD+"<<endl;
  outfile<<i+1<<"\t"<<score[i]<<"\t\tD+"<<endl;
} else if (score[i]>34 && score[i]<40) {
  cout<<i+1<<"\t"<<score[i]<<"\t\tD"<<endl;
  outfile<<i+1<<"\t"<<score[i]<<"\t\tD"<<endl;
} else {
  cout<<i+1<<"\t"<<score[i]<<"\t\tF"<<endl;
  outfile<<i+1<<"\t"<<score[i]<<"\t\tF"<<endl;
}

}
ARYT commented: "do-while"??? :( +1