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

line 27 of the write program: using unitialized arrays: This will fix it. float tempStore[maxTempVals] = {0};

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

>>Because my prof said so :
Ok, so do as he said.

>>I have never done anything in C
Yes you have, but you may not realize it. FILE and associated functions are C. Those C functions just happened to be also supported in C++. But that neither here nor there because your prof said to use it, so end of subject.

Your efforts should be to correct all warnings before complaining that your programs don't work as intended.

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

Please re-read my suggestion -- I didn't notice that you already had a variable x, so I changed my post accordingly.

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

writing to file: why are you using C FILE and associated functions instead of c++ fstream? If you are going to write a c++ program then don't resort to C functions. It'll work but not very good practice or coding style.

You need to pay attention to the warnings that you compiler produces. Treat each warning as if it were an error. For example the following warnings are actually errors:

line 58: using == instead of = assignment operator

line 68: variable index is unitialized.

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

>>cout << "Loan " << x << " For $"
add 1 to x so you get 1, 2, ... cout << "Loan " << x+1 << " For $" >>cout << "has a payment of $" << (double)loanAmount[x]/(double)numMonths[x] << " per month." << endl;
To get the sum of the above, do this in two steps and add them up on another variable

float total = 0;

...
...
float n = double)loanAmount[x]/(double)numMonths[x];
total += n;
cout <<  "has a payment of $" << n << " per month." << endl;

Now when that loop ends the variable total will have the sum of those amounts.

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

By "product manager" do you mean you work for a company that makes widgets with integrated computer and software? Or do you mean you work for a software development house to write computer programs exclusively?

I suspect if you want to work as a product manager for a software house then you will need a pretty firm grasp of programming languages so that you can talk intelligently with the software development team(s). Given you lack of much knowledge in that area 6 months seems like a reach. Take some college courses in software development, and/or get your MBA in computer science. That will probably get you on the fast track to the position you want.

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

>>The problem is it is displaying random numbers stored in the computer
The problem is in the code you did NOT post -- show us the code that contains this line: DisplayEntry(data); Most likely it is passing an instance of a structure that contains uninitialized data.

When you declare the object, do it like this so that all elements are initialized to 0 ProjectileData data = {0};

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

>>i have Visual Studio 2008

Which edition? the free Express edition can only do plain win32 api programs and console program. The program you are describing is a GUI with menus. Not all that difficult to achieve for someone familiar with win32 api programming. If you are not, then do this tutorial.

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

yes, they are the same (probably)

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

line 4: put all includes at the top of the file before anything else. It might compile the way you have it but its not the standard practice to put includes inside functions like that.

As for your actual problem -- don't know.

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

>>does anyone know what to do?
Yes, don't you ?

Use the cos() function in math.h to calculate the cosignes of the numbers read from the data file.

You first have to create the input file(s) probably using Notepad.exe or some other standard text editor from the operating system you are using.

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

Depends on how you want to use it. See this

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

already answered that in your other thread.

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

>>thanks but can you please send me the edited code.
Nope, try it and post what you have done so solve this yourself.

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

In your example just fill in the missing elements with 0 to make both arrays the same size, then do like vmanes mentioned, assuming that's what his teacher wants. And that would explain the need for two loops.

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

>>so I do not know what they are going to be.
Count them as the user enters the numbers. Each time you enter a number increment the counter by 1.

>>you will need to use at least 2 for loops to add the two arrays together,
If array A contains 10 numbers and array B contains 7 numbers, then the first loop counts from 0 to 7 and the second loop only counts from 7 to 10 to get the numbers that are in A but not in B.

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

If you mean matrix algegra then the two arrays have to be the same size.

But lets say you have two arrays

int A[] = {1,2,3,4,5};
int B[] = {2,3,4,5,6};

then array C[0] = A[0] + B[0], and C[1] = A[1] + B[1], etc.

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

>>if(password == Enter Password)

Should be testing for secondnumber if(password == secondnumber)

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

After correcting a bunch of errors I'm back to your original question.

The problem is that there is no constructor with the first paramter as const char*, only const char, which of course is not the same thing.

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

using VC++ 2008 Express, I don't get that error after correcting the 2 :: s
The code you posted contains a lot of other errors too. There are several lines with only one :, and Date::print() is named Date::print2() in the header file.

Here's the errors I get now

d:\dvlp\test2\test2\test2.cpp(30) : error C3861: 'print': identifier not found
d:\dvlp\test2\test2\test2.cpp(36) : error C2143: syntax error : missing ';' before ':'
d:\dvlp\test2\test2\test2.cpp(36) : error C2059: syntax error : ':'
d:\dvlp\test2\test2\test2.cpp(36) : error C2062: type 'const char' unexpected
d:\dvlp\test2\test2\test2.cpp(37) : error C2143: syntax error : missing ';' before '{'
d:\dvlp\test2\test2\test2.cpp(37) : error C2447: '{' : missing function header (old-style formal list?)
d:\dvlp\test2\test2\test2.cpp(41) : error C2143: syntax error : missing ';' before ':'
d:\dvlp\test2\test2\test2.cpp(41) : error C2059: syntax error : ':'
d:\dvlp\test2\test2\test2.cpp(41) : error C2062: type 'const char' unexpected
d:\dvlp\test2\test2\test2.cpp(42) : error C2143: syntax error : missing ';' before '{'
d:\dvlp\test2\test2\test2.cpp(42) : error C2447: '{' : missing function header (old-style formal list?)
d:\dvlp\test2\test2\test2.cpp(48) : error C2470: 'Date' : looks like a function definition, but there is no parameter list; skipping apparent body
d:\dvlp\test2\test2\test2.cpp(53) : error C2470: 'Date' : looks like a function definition, but there is no parameter list; skipping apparent body
d:\dvlp\test2\test2\test2.cpp(61) : error C3861: 'print': identifier not found
d:\dvlp\test2\test2\test2.cpp(97) : error C2664: 'Date::Date(int,int,int)' : cannot convert parameter 1 from 'const char [5]' to 'int'
        There is no context in which this conversion is possible
d:\dvlp\test2\test2\test2.cpp(101) : error C2664: 'Date::Date(int,int,int)' : cannot convert parameter 1 from 'const char [9]' to 'int' …
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is how to format the code. I also change a couple of other errors -- you had << and >> reversed. cout uses << and cin uses >>, you have them backwards.

>>if(password == Enter Password)
That is also wrong but I don't know how you need to correct it.


Help with Code Tags (Toggle Plain Text)

int main()
{
    int secondnumber;
    while(true)
    {
           cout << "Enter Password";
          cin >> secondnumber;
          if(password == Enter Password)
          {
               cout<<"Welcome Lukus";
          }
          else
          {
               cout<<"Password Rejected";
         }
}
system ("PAUSE")
return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

braces are still wrong -- they are backwards and the closing } is on the wrong place. Re-read my previous post again. You need to count the number of opening and closing braces and make sure there is a } for every { (and vice versa)

line 11: delete the semicolon at the end of that while statement

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

date.cpp:
>>Date:Date
That should have two :, not one
Date::Date

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

I have some shares in the Golden Gate Bridge that I'll sell him too. :)

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

You need to add { and } when there are more than 1 lines within while statements

while( <condition> )
{
   // some lines here
}
else
{
    // more lines here
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

2012 is the year london is supposed to hold the olympics, but nothing is built yet.

Why should you brits waste your money on something that won't (can't) happen? There's no point building something that will just get destroyed before you can use it.

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

Sounds a bit like the movie Victor Victoria. Great movie :)

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

>>int main ();
Of course not -- get rid of the semicolon!

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

>>wat should i put in here also?)
identical to main()

int abc(int argc, char* argv[]);
int main(int argc, char *argv[])
{
    abc(argc, argv);
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 8: don't you see something a little strange about that line? hint: () and ;

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

>>So i rather do not think about anything
So your mind is totally void of any thought :)

>>I would like to exist some organization who kills people who do not like to live because I did not ask anyone for life .(
Actually there are a few who do that. If you are looking for someone to kill you I'm sure we can accommodate you.

>>I did not live before 1986 so ,I can said that hole world is set up because of me . And created just before that time

Oh I see -- The universe and everything in it did not exist before you were born. Is that what classes in Philosophy does to students minds ? I'm glad I avoided them :)

>>The scientist said about intelligence but I do not trust them why should I when they are
>>all human with greed .And I do not trust even in the church why should I ? I trust in my
>>act only . Not even my parents I always check what they are puts in my food

OMG are you really paranoid! Do parents often poison their children in your country ?

>>So today normal people can said that I am a mad man and I need to go into madhouse
Sounds like an accurate assessment to me.

>>Look at this , when you are a poor you want to get rich

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

I think most of us do care about the animals, its just that we don't care about online petetions.

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

>>I was hoping for just a giant list of every list in the dictionary
which dictionary? there are quite a few of them and they all contain a different set of words.

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

Thats in the article. So, Mr. Beatie was Ms. Beatie more than 10 years ago. Then she decided to turn herself into a man. But then, she thought, oh, I should create history by becoming first "man" to be pregnant. So, she decided to keep her reproductive organs so that she can give birth to a child. Then, on one fine day, Mr.Beatie (with female organs) became pregnant ! Thats got nothing to do with woman,evil thing, snake, tree, etc.

Since Mr Beatie got pregnant does that make him gay ?

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

Kv79: Apparently you can not detect scarcasm when you read English. What I posted was just a joke, not meant to be taken seriously.

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

since its binary data it will be better to read it into unsigned char array. There is one way to do it.

unsigned char* buf = 0;
size_t filesize = 0;
FILE* fp = fopen("sound.mp3","rb");
// get the size of the file and allocate input buffer space
fseek(fp,0,SEEK_END); 
filesize = ftell(fp);
// go back to beginning of file
fseek(fp,0,SEEK_SET);
// allocate input buffer
buf = malloc(filesize);
// read into buffer
fread(buf,1,filesize,fp);
fclose(fp);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

line 25: fscanf() returns an int, not a char.

line 26: should check for both 0 and EOF.

line 31: you can't compare two strings like that. You have to call strcmp() if( strcmp( temp, nrow) == 0) line 32: That break will stop the loop started on 28 and do nothing for the earlier loop. If that's what you want then its ok.

lines 34, 35 and 39 are unnecessary. You don't need an else after that if statement on line 31.

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

First you will need an int array that contains the cumulative number of days in each month. For example: int days[] = {0, 31, 59, ... }; Next chop up the string into its individual int elements.

Then determine if year is a leap year, if so then add one to days[2] (which is Feb) and each of the other days elements beyond 2.

Now for the actual calculation.
1. Find the number of days from 1 Jan to the start of the specified month. To do that subtract 1 from the month and then get the number of days in that month from the days[] array. Example: January = 1 - 1 and days[0] = 0, Feb = 2 - 1 and days[1] = 31 because there are 31 days between 1 January and 1 February.

2. Finally just add the spefied day to the above total.

If I enter a the date 1 Feb 2008 then first get days from 1 Jan to, but not including, 1 Feb, which is days[1]. If I enter 1 March 2008 then its days[2] = 59 (or 60 if a leap year).

If I enter 17 March 2008 then its days[2] = 59 + 17 = 76.

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

hi gazoo,

if you want to check whether feb, 29 exists, then why not starting simpler than your code from line # 57 et seq. Maybe this way:

int year = 1800, month= 2, day = 29; // merely a test case

   if (leapyear(year))
   { cout << "yes, it's a bisextile" << endl;
   }
   else
   { cout << "no, not a bisextile" << endl;
      if ( month == 2 && day == 29 )
          cout << "sorry, no bisextile day in " << year << endl;
   }

krs, cliff

How many ways can you spell bisextile ? :)

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

Arnold was pregnant once -- I know because I saw his movie. Here's proof. :)

And here's more about pregnant men.

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

A pointer *p is not necessarily a pointer to an array. It could be a pointer to some object

void foo(int* p)
{
    *p = 0;
}

int main()
{
    int x;
    foo(&x);
}

or a pointer to an array of ints

void foo(int* p)
{
    *p = 0; // set first element of the array to 0
}

int main()
{
    int x[20];
    foo(x);
}

In the above two examples the function foo() must know whether it is getting a pointer to a single object or to an array. And the calling function must pass the correct type of pointer. If there is a mismatch then the program will most likely crash. And that is one of the most common types of errors made by C programmers.

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

That's the same as I posted, but this: for(index1=0; index1 < strlen(sentenceHolder1); index1++) You don't want to call strlen() like that because it has to be executed on every iteration of the loop. Code it once as I did and just use that variable.

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

Any help with how to replace an instance of a character in the array with the first character of the array would be greatly appreciated :)

sentenceHolder1[i] = sentenceHolder2[0]; will replace a character in sentenceHolder1 with the first charcter in sentenceHolder2.

>>Yea I wasn't planning on handing that part in, my prof just suggested in one of our classes that it
>>was possible and I was wondering how you could do it because he won't tell me.

Yes it is possible. Hint: strstr() from string.h is your friend when working with charcter arrays. There are better ways when using c++ std::string class, but you probably have not gotton to those in your class.

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

I don't know if you can duplicate the problem with your own thread. Try changing the code tags in c++ board in an existing thread that has not already been changed by a mod.

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

>>But, by the way, do you know why I have to locate the file somewhere else?

The file must be in the same folder that your program is running in unless the open statement tells it otherwise. For example ifstream in("c:\\myfolder\\temp.txt");

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

Stick to the program requirements and don't try to do fancy stuff. Your task is to code what the prof asked you to code, not to make up stuff on your own.

There isn't anything wrong with trying out various things on your own -- just don't hand any of it in as part of the assignment.

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

line 9: If you want someone to type up to 20 characers then you have to define charString as 21 in order to allow room for the null string terminating character.

line 23: All you want here is to enter a single character, not an entire string. Similar to line 26.

lines 29-42: all you need here is just one loop to test each character in sentenceHolder1 for the character you enter on line 23 and possibly replace it with the replacement character.

int len = strlen(sentenceHolder1);
for(int i = 0; i < len; i++)
{
    if( sentenceHolder1[i] == look_for_character )
        sentenceHolder1[i] = replacement_character;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Today I find that when I change a post code tags from

[code]

blabla

[/code]

to this [code=cplusplus] blabla

[/code]

It doesn't work and acts as if something were misspelled or code tags were not present. But when I erase the [code] and retype the whole thing it works ok. Are there some hidden characters in that line causing the problem? I've had that problem 3 or 4 times this evening.

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

The compiler pushes the value of each variable contained in the structure onto the stack as if they were individual integers (or whatever POD they happen to be). But C or C++ programmers don't really have to be concerned about that (at first) because inside function1() it is treated as a structure, not as individual elements of the structure.

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

You have to have the file opened for output if you want to add a line to the file. Then seek to the end of the file and write the new data.