>>if someone could start the code for so it might be easy to continue
Start with this:
#include <iostream>
using std::cout;
int main()
{
// put your code here
return 0;
}
>>if someone could start the code for so it might be easy to continue
Start with this:
#include <iostream>
using std::cout;
int main()
{
// put your code here
return 0;
}
It will help to know what inputs you used that caused the problem.
matrix[i][j]= {" ------------ ---------------------- \n","| | |____ | | | |__ | ____ | |\n","| ____ |___| | | | __|_ | |____| _ |\n","| |____| | _|_ |__ | | | __|_ | |\n","|_|_ _____ | |_____ ___|\n","| ___ |_ | ________ | |\n","| | | ____ | | ___ |___ |\n","| | | _| | | ___| | | | |\n","|_| |___ | | | |_ | __|__ | |\n","| __ ___| |______ |_______ | |\n","|__| |___ ___ |___________| |_|_|_| |\n","| | | _____|_ | |\n","| __ _____|_|___| | | |\n","| | | | ___ |___ ___ |_|___ \n","| | |_|_| | _______ | _|_ \n","| | | | | | | |__________| | _____|\n","| | |___|____| | | ___ __|_____| |\n","|_____ | | __________| ___| |\n","|_____ | |_| _____| | |\n","| | | | _|_ | | |\n","| | |___ | _________| |__|\n","| | | | | | |_|_| ____|\n","| | |_____| |_|_ | | ____ |\n","| |____| ______ |___ | | _ | |\n","| | | | | | | | |\n"," ------------------------ ----------- \n"};
That matrix can not be initialized like that -- you have to use strcpy() to copy all those strings into the array elements.
strcpy(matrix[0],"------------ ---------------------- \n");
strcpy(matrix[1],"| | |____ | | | |__ | ____ | |\n");
// etc. etc
or initialize the matrix on the same line where it was declared.
>>Nuking them will trigger an outrage.
Yes of course it would, and it should. But as I said if we as a nation decided to go that way I doubt there will be another terrorist attack anywhere in the world because we would just nuke them whereever they happen to be. Nice to think about, but to be realistic it isn't even the remotest possibility.
On another site im on people are having a QUICK REPLY issue also,i am trying to figure out whats causing it....
What Mode are you using Dragon??
Threaded Mode
Linear Mode
Hybrid Mode
Im using Linear and have no issues (And i dont on the other site either using the same mode)
Linear (Oldest first). I have not had the problem since I cleaned out the temp internet files. But it has not been long enough to determine whether that fixed the problem or not.
A good way to make friends around the earth. All the countries receiving the nuclear fallout would sue us for decades! Would keep the lawyers busy and our treasury empty (emptier than it already is). We would have to go to the Chinese and borrow even more money.
They can't sue us if they're all dead :) One problem, of course, with my suggestion is that some of those nations can shoot back and we might get a taste of our own medicine.
The problems I mentioned are not memory leaks. That is another problem. If you use <vector> or <list> you can avoid rolling your own links and all the problems they inherently have.
Probably because the program has trashed memory before the line with that new statement was executed. Uninitialized pointers, buffer overruns and writing beyond the bounds of arrays are the most common reasons.
it wasnt meant to be smily but "; )"
fixed it for you, scroll down and you will see a checkbox to disable smileys in the text.
All the ones that eventually repented will be there. EnderX is the authority here, ask him.
True, Buckley might have repented too, we don't know one way or the other and its really none of our business. But with his eago it doesn't seem very likely.
Welcome to DaniWeb -- hope to see you around.
But that hasn't stopped the terrorists, or is it that terrorists are too stupid to realize they are outgunned. And if they are outgunned why didn't we defeat them in Iraq years ago ? Answer: politics, we could have just nuked that country and been done with it, or bommed it into the stoneage.
>>shouldn't it have?
Not necessarily. The compiler would have complained if Vector.h included Point.h and Point.h included Vector.h.
But I make it a habbit of using those code guards because (1) the header file looks naked without them and (2) never know when I might decided to include the header more than once.
Why do you want to convert that code to switch? It's not a good candidate for that.
line 3: where is dir declared ?
line 5: The == operator is a boolean operator, not an assignment operator. So, as writtin, that line does nothing. If you intend to set row to the value of selectX then you have to use the assignment operator =, not ==.
GetPoint() still remains a method of the class, just put the code in a *.cpp file
// cpp file
Point Vector::GetPoint()
{
// code here
}
>>doesn't that mean you need to have #ifndef statements?
Yes. But you should do that anyway just out of habbit
I don't get the problem you have. I changed the do loop to a while loop and deleted the line that said i -=2;
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
long IDs[255] = {0};
float Scores[255][4] = {0};
int main()
{
ifstream text("data3.txt");
if(!text.is_open())
{
cout << "Error opening file\n";
return 1;
}
int i = 0;
while(i < 255 && text>>IDs[i] && IDs[i] > 0)
{
text>>Scores[i][0];
text>>Scores[i][1];
text>>Scores[i][2];
text>>Scores[i][3];
i++;
}
text.close(); //Closes open stream.
for(int k = 0; k < i; k++)
{
cout << IDs[k] << " ";
for(int j = 0; j < 4; j++)
cout << Scores[k][j] << " ";
cout << "\n";
}
}
produces this output
66.8 90.9 87.7 65.6
99.5 88.8 55.9 94.5
88.8 77.6 66.6 89.9
90.4 77.3 72.2 68.8
77.2 77.8 88.3 83.2
55.9 89.9 82.2 84.6
98.8 93.5 94.1 90.2
89.9 33.5 76.4 67.1
66.5 55.7 55.8 44.9
88.9 88 81.4 82.4
66.7 56.8 71.2 65.9
55.5 66.6 66.2 62.1
67.3 77.8 65.9 87.2
99.3 92.2 87.8 90.3
66.1 62.6 54.1 45.2
55.4 34.4 23.4 77.1
77.4 66.8 75.5 75.2
80.3 78.9 71.4 62.2
77.8 77.9 72.4 80.1
99.9 89.9 99.9 94.6
66.7 77.1 76.6 79.3
88.2 82.2 78.9 68.3
98.3 89.3 78.4 99.4
77.9 34.7 78.9 78.4
56.6 45.6 34.5 23.8
66.7 56.2 78.9 55.9
92.3 92.3 94.3 80.2
90.9 88.3 88.8 91.1
76.8 87.4 87.1 79.3
55.8 89.9 78.2 90.3
66.8 90.9 58.4 69.4
69.9 78.7 50.2 67.5
77.9 71.2 76.7 75.3
82.2 81.9 72.6 75.6
98.3 87.3 93.7 89.2
77.3 66.3 74.8 50.6
66.2 67.3 72.1 45.6
88.8 59.2 67.7 90.5
55.5 66.6 54.5 59.9
77.8 98.2 88.3 78.5
88.8 67.8 86.6 78.2
45.5 56.5 34.6 55.6
any key to continue . . .
there is something else wrong then. Post your newest code.
Indexing into the second dimension of Scores is wrong, causing boundry overflow and scribblins all over memory. See below.
text>>Scores[i][0];
text>>Scores[i][1];
text>>Scores[i][2];
text>>Scores[i][3];
You can not create an class object unless the class is fully defined. If all you have is a forward reference then all you can do is create a pointer of that type.
[edit]try ^^^^ mitrmkar's suggestion [/edit]
Welcome to DaniWeb. I consider myself to be mechanically disadvantaged -- don't know a screwdriver from a shudge hammer :) It takes 100% of my mechanical ability to find the hole to fill up the gastank. But there are a lot of other very capable people here at DaniWeb who can help you out with your computer problems.
When writing in-line functions you can not leave out the variable names. What you have on line 2 is a data type -- Date is a class, not the name of an object. Code it something like this:
Licenses::Licenses(int id, string name, string ad, Date dt1, Date dt2)
:issue_date(dt1), expiry_date(dt2) // error occurs here
{
Welcome to DaniWeb, and good luck with your program :)
Welcome to DaniWeb. And --
1) So am I sometimes
2) Yup, me too
3) how can something be useless if its difficult ?
4) I was only wrong once in my life, when I thought I was wrong, but I was wrong. :)
>>Season's Greetings
Procrastinating ;)
Hope to see you around DaniWeb.
>>Swallowing spit causes infection (if ur suffering from cold or disease).
Better not kiss anyone then :)
grandtotal us used both as a function and a variable name. You can't do that. See lines 17 and 34 (as well as others)
line 59: max is undefined. But I guess you would have know that had you read your compiler's error messages.
Nice looking code. Is there a point to your thread?
>>but why they need engineers, doctors and computer scientists to serve as soldiers???
Just who do you think supplies all those weapons, cloths, food, housing, tends to wounds, etc? I heard once that it takes 10 people to support 1 soldier.
>>no vacations
US active duty people get 30 days paid vacation a year. When I was on active duty and in VietNam we also got a week R&R (Rest & Recouperation) at a resort outside the war zone. Don't know if they do that in Iraq or not. We also got special combat pay and no federal or state taxes while in combat zone. I reinlisted while in VietNam and my reinlistment bonus was also tax free.
Just like every other occupation military life is not for everyone. Not eveyone has the guts it takes to be a succful soldier. If you really hate it then my suggestion is to get out when your time is up and do something else that you do like.
lines 53-60 are still incorrect. You should not have used nested if statements
for (i = 0;i < numTemps;i++)
{
if ( temp[i] > maxtemp)
{
maxtemp = temp[i];
}
if ( temp[i] < mintemp)
{
mintemp = temp[i];
}
cout <<"The minimum temperature is:" << mintemp << "in reading #" << i << "\n";
}
Now your talking gibberish. Please explain what you mean.
My personal favorite was an investment telemarketer, with a "tip".
After telling me how well it would do, he used the close, "and we could all use more money, right?" I answered "no". Half way through his next sentence he stopped and attempted to recover, "no really?" I said, "no really. If I had any more money I just wouldn't know what to do with it anyway."
He wrestled, quite clumsily, for a moment. Then, when I wouldn't budge, he excused himself.When board, it can also be fun seeing just how long you can keep THEM on the call.
That is funny, it reminded me of some obscene phone calls I started getting about 20 years ago when I lived in California -- they were all from the same young lady (girl). Finally I got tired of them so I kept her on the line, the longer I talked the more vaulger I became. After talking about all the dead women I had in my back yard she hang up :) I never heard from her again (whew!)
Yes it will because you didn't declare a variable
char *p = "Hello World";
char c = *p;
In the above, c has the value 'H' which is the first letter of the string pointed to by the pointer p.
The value stored in the pointer variable is the address of the data. Desn't matter what type of data (char, integer, float, double, char array, c++ class, etc).
The two loops at lines 51 and 60 can be combined into one loop then find both min and max within the same loop because its more efficient that way.
line 62: min doesn't work because you have the test backwards. Use the < operator instead of >.
OMG that was pretty quick work! Guess you decided not to do bold and underling then.
>>guessing you can't help me because you're thinking i'm not showing some effort
Never said we can't help you -- just trying to find out how much you really know.
i'm guessing this will require me to create an output file,which i have no idea yet
well,it's safe to say that i'm not that someone.
You're not ??? If you are that knowledgable why don't you know how to to file stuff?
>>please correct this program... please!! i need it badly
So, what is wrong with it?
line 25 uses the wrong input function. fscanf("%s" ...) stops reading on the encounter of the first space. You should use fgets() instead to get the entire line
while( fgets( numIn, sizeof(numIn), spIn) )
{
// strip the trailing '\n'
if( numIn[strlen(numIn)-1] == '\n')
numIn[strlen(numIn)-1] = = 0;
// rest of code here
}
>>I'll have to read up again to remind myself how to do the line numbers, apologies for that
Not a problem -- I just like to see them. Here's how
[code=cplusplus] // your code here
[/code]
line 8 is also wrong in this and the previous post. should be hightemp = hourlytemps[i];
>>are those things mentioned complex?
Yes, for someone who doesn't know anything about c++.
You need to learn the C++ language before attempting a program that complex. Learn to crawl before running full speed. Buy an introduction to C++ book and start studying at page 1, and do all the exercises at the end of each chapter. Don't skip chapters unless you already know the material from some prior programming experience.
line 7 is wrong. Should be testing against hourlytemps, not the loop counter. if( lowtemp > hourlytemps[i])
Oops! I see that now. Your function is correct afterall. Please forgive an old man -- blind in one eye and can't see out of the other :)
Done. Now I'll report back if it happens again.
it happened once that I recall yesterday too, but more often today. At first I thought it might be my ISP, but that doesn't make sense with that error message. Might it be getting submitted twice instead of only once ?
Just happend again.
I was thinking if the first argument is NULL then there are no other arguments.
I have a function written to display my output, but I've never called a display function before and I'm not sure how to do it. Here is the function
void displaytemp( const int hourlytemps[], int numtemp, double averagetemp) { cout << " Average Temperature: " << averagetemp << endl; }
how do I call this in main?... I know it's not really necessary to create an output function, it's just practice writing functions and calling stuff from arrays and other functions
Call it just as you would any other function
int main()
{
int hourlytemps[24];
int numtemp;
double averagetemp;
displaytemp( hourlytemps,numtemp, averagetemp);
}
Your function displaytep() is also incorrect. You can't display an array like that -- have to print each element one at a time, something like this:
displaytemp( const int hourlytemps[], int numtemp, double averagetemp)
{
for(int i = 0; i < numtemp; i++)
{
cout << hourlytemps[i] << "\n";
}
}
You can not put array declarations in a header file then include that header file in two or more *.cpp files. If that's what you did then you should declare the array with the extern keyword everywhere except in ONE and only ONE *.cpp file.
// header file
[b]extern[/b] int array[8];
Then in a *.cpp file declare it again without the extern keyword.
I've had this happen several times today -- push the submit button and an error message is produced. If I refersh the page my post was made correctly.
Actually I think you could implement something like you want if you pass NULL as the first argument and check for that value in the parameter list
void foo(const char* fmt, ...)
{
if( fmt != NULL)
{
// blabla
}
else
{
// do something else
}
}
AFAIK the draft used to apply all the time but I don't recall having mandatory military service when we were not at war. we have not had mandatory service or the draft for quite a few years now (ended in 1973). Since then an all voluntary military force has worked pretty well, millions of brave men and women have volunteered to fight for their nation.