necrolin 94 Posting Whiz in Training

Well, you set n to zero on line 7 (n = 0;) and then you never change it so it's obviously still zero. Remember that == checks for equality. It does not set num to equal anything. Therefore, num==a; should be num = a; and then continue the same pattern on lines 9-11.

necrolin 94 Posting Whiz in Training

You'll have to install whatever libraries provide you with these "missing" headers. They do not come with Visual Studio, nor do I believe they are a part of the C++ standard. itpp/itcomm.h appears to be part of the IT++ Communications library. Google the header files and you should be able to find what you're looking for.

necrolin 94 Posting Whiz in Training

Part of this program doesn't make much sense to me. First, you have:

double axx1;
float xx1 = 0;

Then you do some calculations and then:

axx1=xx1;

Converting from a float to a double doesn't do anything at all for you. If you want more precision then why don't you just use doubles all the way through the program? I believe that the math functions that you use (sin, cos, tan) can take floats, doubles, and long doubles so you'll be fine and you'll get an answer that's closer to what you're looking for due to the extra precision that you'll get.

You may also consider formatting the output to limit the number of digits after the decimal.

necrolin 94 Posting Whiz in Training

According to the book "Thinking in C++" the second example is the "old" way of doing things while static_cast<> is the "new" way. So, the old way would be the kind of code you'd see in C while the static cast would be the C++ way of doing things. (From pg 169)

necrolin 94 Posting Whiz in Training

if u wanna be a dick dont respond to my questions

Actually what WaltP stated was correct. You're not calling any function that makes the computer wait 10 seconds. Instead of calling him names a more constructive approach would be to state that you realize that you're not calling a function to make the computer wait because you have no idea how to implement such a function yet and that's fine. No problems. But do try to be polite.

There's more than one way to implement a wait period. Here's one solution for you:

http://www.daniweb.com/forums/thread65024.html

necrolin 94 Posting Whiz in Training

Are you hiring? If so my hourly is $200 USD. Send me a check and I'll send you the code. If you think that we're going to do your homework for you just because you're too lazy to do it yourself it's not going to happen. Nobody is going to do this work for you. Write the program yourself. If you get stuck somewhere along the way then send us your code and we'll help you fix it. That's what we do here. We help. This is not a homework doing agency for students that don't feel like studying. Sorry.

Salem commented: Nice +17
necrolin 94 Posting Whiz in Training

What kind of errors are you getting?

Your program compiles just fine in Code::Blocks using the current version of Mingw.

I'm wondering if you have Mingw installed on your computer. Could you double check for us please? There were 2 versions of DevC++, one with a compiler and the other without. You may have the one without the compiler... hence the errors. No way of knowing without reading a few of the errors though or checking your install.

Also, conio.h is not really a part of standard C/C++. Try compiling without that line and see if you have any luck. I'll quote wikipedia on that one: "conio.h is a header file used in old MS-DOS compilers to create text user interfaces. It is not part of the C programming language, the C standard library, ISO C nor is it required by POSIX."

necrolin 94 Posting Whiz in Training
#include <iostream>

using namespace std;

int main(){


    int size;

    cout << "How big is your array going to be?";
    cin >> size;
    int* ptr = new int[size];

    // Enter numbers into array.
    for(int i = 0; i < size; i++)
    {
        cout << "Enter Number: ";
        cin >> ptr[i];
    }

    cout << "Numbers entered into array are: " << endl;
    for(int i = 0; i < size; i++){
        cout << ptr[i] << endl;
    }

    // Now i want to add more number to this array.
    int newSize = size + 3;
    int* newPtr = new int[newSize];
    memcpy(newPtr, ptr, size * sizeof(int));
    delete []ptr;
    ptr = newPtr;
    ptr[size] = 99;
    ptr[size + 1] = 100;
    ptr[size + 2] = 199;

    cout << "New array looks like:"<<endl;

     for(int i = 0; i < newSize; i++){
        cout << ptr[i] << endl;
    }

    delete []ptr;

    return 0;
}

Make a new array of larger size and copy the contents from one to another will do the job.

necrolin 94 Posting Whiz in Training

Also, note that using void* makes it very easy to make mistakes. I wouldn't recommend doing that. Use a proper struct, class, or union and you'll make life a lot easier for yourself.

Clinton Portis commented: Good clear example on a topic that had me stumped. +5
necrolin 94 Posting Whiz in Training

If you want it to be an array you can do what Clinton was doing minus the mistakes. Try this code, it compiles just fine under gcc

#include <iostream>
using namespace std;

int main()
{
    int a = 1;
    double b = 2.0;
    char c = 'c';
    string d = "It works!!!\n";

    void* array[4] = {&a, &b, &c, &d};

    cout << "array[0] = " << *(int*)array[0] << endl;
    cout << "array[1] = " << *(double*)array[1] << endl;
    cout << "array[2] = " << *(char*)array[2] << endl;
    cout << "array[3] = " << *(string*)array[3] << endl;

    return 0;
}
necrolin 94 Posting Whiz in Training

OK, I see where the problem is. It's an easy one, but I missed it the first time I looked at the question.

if number1 > number2 then highest = number1.... and it stops checking right here. The moment one if statement is true then that's the end of the if/else if sequence and so it doesn't try to check past the first result that comes back true. You need to use individual if statements and not else if statements to make this work.

#include <iostream>
//include <conio.h>

using std::cout;
using std::cin;
using std::endl;

int main ()


{
	double total=0,num1,num2,num3,num4,num5,high,low;


	cout << "Please enter number: ";
	cin>>num1;
	cout << "Please enter number: ";
	cin>>num2;
	cout << "Please enter number: ";
	cin>>num3;
	cout << "Please enter number: ";
	cin>>num4;
	cout << "Please enter number: ";
	cin>>num5;

	high = num1;
	if (num2>high)
	{
		high=num2;
	}
	if(num3>high)
	{
		high=num3;
	}
	if (num4>high)
	{
		high=num4;
	}
	if (num5>high)
	{
		high=num5;
	}

	cout<< "The highest number is " << high;

	return 0;
}
necrolin 94 Posting Whiz in Training

If you set the highest number to the first number, then why would you compare the first number to the highest to see if it's bigger?

high=num1
   if (num1>high) high=num1;

It's not wrong, it just doesn't make much sense. If the highest number so far is number 1 then start comparing with number 2.

The code looks fine. What's the problem that you're getting?

Also, like jonsca wrote, if you use an array/vector and a simple for loop then you'll save yourself a lot of typing. (If you've gotten that far in the language, if not then portion of the program that you posted looks like you're doing things right.)

necrolin 94 Posting Whiz in Training

You have one of a few choices:

1. Convert your function from returning an int to returning a string
2. Convert MyName to an integer.... maybe something like MyID
3. Convert your function to return a void* and then cast it to a string...

Of these choices, option 1 is the best. You cannot return a string when you are specifically telling the program that it must return an int.

My ideas in code:

#include <iostream>
#include <string>

using namespace std;

string MyName()
{
    return "Hubba Bubba";
}

int MyID()
{
    return 1234;
}

void* MyName2()
{
    static string name = "Hubba Bubba Jr.";
    void* temp = &name;
    return temp;
}

int main()
{
    string name1 = MyName();
    void* name2 = MyName2();
    int ID = MyID();

    cout << name1 << endl;
    cout << *(string*)name2 << endl;
    cout << ID << endl;

    return 0;
}
necrolin 94 Posting Whiz in Training

This one works, not super elegant, but it works. You'll have to eliminate your marker if you want.

#include <iostream>
#include <iomanip>
#include <string>
#include <stdio.h>

using namespace std;

int main(void)
{
 char s[50];
 cout << "\nEnter String to Remove Spaces from: " << endl;
 gets(s);
 int len = strlen(s),j=0;

//This will keep track of where we are
 int currentPosition = 0;

 //Clear left side only, stop at a '*' character
 for(int i = 0 ; i < len ; i++)
 {
     //Declared before the for loop so it will persist after loop ends
     currentPosition = i;
     
    if(isspace(s[i]))
   {
     j=i;
     for(;j<len-1;j++)
      s[j] = s[j+1];

     if(i!=j)
      {
       s[j] = '\0';
       len--;
      }

     if (s[i] == '*')
     {
         break;
     }
   }
 }

 //Clear right ride from the '*' character
 for(int i = currentPosition ; i < len; i++)
 {
    if(isspace(s[i]))
   {
     j=i;
     for(;j<len-1;j++)
      s[j] = s[j+1];

     if(i!=j)
      {
       s[j] = '\0';
       len--;
      }
   }
 }

 cout << "\n\nNew Sting After Removing Spaces: " << s << endl;

 cout << "Program paused...";
 cin.get();

 return 0;
}
necrolin 94 Posting Whiz in Training

The way that you do this exercise is you bust out your handy dandy computer, use your problem solving skills to work it out yourself, try to compile the program, and if you still have problems you ask on a forum. You've just posted 3 of your homework assignments with absolutely no code and no effort put into doing them yourself. Common what are you trying to do? It's your homework not ours.

necrolin 94 Posting Whiz in Training

The only error in this file is horrible formatting. The program compiles and runs just fine.

necrolin 94 Posting Whiz in Training

I don't mind helping you out but you're not asking for help. You're asking someone to do your homework for you. Try it out on your own. Show us the source code you have and we'll help you fix the mistakes.

Salem commented: Well said +36
necrolin 94 Posting Whiz in Training

VirtualBox

You can create a virtual machine and install Ubuntu inside Windows or vice versa. This way you can run 2 systems at the same time. What I did was I used OpenSolaris for the entire drive, installed Windows inside VirtualBox and never need to reboot. Note that this will not be running Ubuntu off of your second partition. You will have to actually do a fresh install inside Windows where it will appear as a really big file.

Salem commented: Yay :) +36