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

>>when I compile, there are no errors,
Ditch the compiler and use a different one. There is a link error.

>>void print ()

Wrong. should be void testClass::print ()

Gem74 commented: It worked! error solved! +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

which ones did you find??

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

Is this what you are looking for?

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

you mean this??

std::string command = "wget http://www.google.com";
system(command.c_str());
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) Are you compiling for UNICODE?

2) what compiler

3) how is UPDATE_DIR declared

4) note that %s and %S are not the same thing. See this

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

You need two loops to do that. You have to check each number against all the previous values.

int a[10] = {5,6,7,8,9,10.11,12,13,1};
int i,j,isTrue;
isTrue = 1; // assume true
for(i = 0; i < 9 && isTrue == 1; i++)
{
    for( j = i+1; j < 10; j++)
   {
       if( a[i] > a[j] )
       {
             isTrue = 0;
             break;
      }
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

read this. I'm not going to do your homework for you.

BTW there is no such thing as "%n" in scanf. The link I give you contains all the valid characters you can put after the % sign.

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

either fmod() or modf(), I'm not sure which one you want. Use google and look them up if you don't know what they do.

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

Please don't use it. Get Code::Blocks.

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

try this: compiled with vc++ 2008 express

#include <windows.h>
#include <iostream>
using std::cin;

int main()
{
    HWND hWnd = GetConsoleWindow();
    ShowWindow(hWnd,SW_MAXIMIZE);
    cin.get();
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What problem are you having? You need to post the code you have tried. If you have not started yet, why not? Do the program in small steps -- do the first part first. When that is finished and tested, then move on to the second part.

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

You are passing vowel incorrectly. The & symbol is used in main to pass vowel by reference, then the * pointer is used in the actual function

void generate_random_vowel (char* vowel)
{
    *vowel = 'a';
}

int main()
{
   char vowel;
   generate_random_vowel( &vowel );
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

in a loop, use % operator to get the last digit, then /= operator to shift digits right and drop the last digit.

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    int x = 123;
    string a;
    while(x > 0)
    {
        int n = x%10;
        x /= 10;
        a += (char)(n + '0');
    }
    reverse(a.begin(),a.end());    
    cout << a << '\n';
    return 0;
}

[edit]Or better still, use previously posted examples which use stringstream class. They are a lot simpler than what I posted here.

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

win32 api doesn't work on non-Windows platforms, but this code snippet will work with some possible mods to the defines at the top.

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

write MS-Windows Device Drivers -- get the DDK here

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

line 41: That is a horrible way to test for eof -- all you need is this:

while( getline(inputFile, line) )
{
    cout << line << '\n';
}

lines 55-60: WTF??? You can not code nested while loops like that and expect anything other than the results you got.

while( inputFile >> name >> a >> age >> number)
{
   // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Check the OnTimer event handler, maybe there is something that causes the window to be repainted.

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

lines 74-80: you don't need to call strcmp() to compare two std::string objects -- just use their == operators if(type == normal) Recode lines 98-105 similarily.


Also those if statements will give you a false validity result. Lets say the type is gold. The very first if statement about normal will set valid to false, which is incorrect. The way to do it is to have just one if statement that tests all of them at the same time

if( type != normal && type != silver && type != gold && type != plat)
    valid = false;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
void foo(const char* str)
{
   // display the string contents here
}

int main()
{
   foo("Once upon a time ...");
   foo("there were three little pigs.");
   // etc etc
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

y not? stdio.h is not used in c++ programs, only C programs. conio.h is not recommended because its no-standard and not supported by very many compilers.

stdio.h defines FILE structure and associated functions. This is for file read/write. In c++ programs we would use <fstream> instead of stdio.h

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

make a function out of that code then send the strings to it.

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

if you mean char yes; then just delete them.

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

put a system pause between letters. Assuming you are coding on MS-Windows.

#include <windows.h>
...
...
string msg = "This is a test";
for(int i = 0; i < msg.length(); i++)
{
    cout << msg[i]; cout.flush();
    sleep(1000); // delay 1 second
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

delete line 40 because it is hiding the declaration in the class itself.

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

Got this link from twitter -- theEllenShow

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

Well, you have to change the rest of your code too so that it uses 'y' and 'n' instead of yes and no.

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

First, get rid of that global cArray. In the class constructor allocate the required number of elements, such as aPtr = new Course[MAX]; . You will also have to create a class destructor to destroy that array with the delete[] operator.

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

Post code to get any help.

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

code tags: look in the Quick Reply box and you will see an explanation of them in the watermarks (light grey text). If you can not see them, then just put [code] at the beginning of the code and [/code] at the end, like this:

[code]

// your program goes here

[/code]

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

First problem is that aPtr is declared in the class constructor. It needs to be declared in the class itself so that it can be accessed by other class methods.

What is cArray? You should probably post the class itself so that we can see what you are doing.

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

Edit your post and use code tags to make it easier to tell you what is wrong with it.

For starters, you do not need the two variables called yes and no. What you have to do is check for 'y' or 'n' if( yn == 'y') And remember: = is the assignment operator, == is the comparison operator. Don't confuse the two.

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

use the mod % operator to check of the number is odd or even. When (number % 2) == 0 the number is even.

make the data type of number an int, not a char because you can't enter a number greater than one digit in a char. You will also have to change the while loop on line 26 while( number != 0)

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

Interesting assignment, except for the requirement to use system("cls") to clear the screen. But that's your teacher's problem, not yours.

1) Your validation for months should test if the number entered is less than 1 or greater than 12. If it is, then print an error message and make the user re-enter.

2) You need to use { and } around the while statement beginning on line 43. Without them only line 45 will get executed within that loop.

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

What dialog box -- there are no buttons or menu item to do that.

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

Like this:

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
                 if( checkBox1->Checked)
                 {
MessageBox::Show( "CheckBox1 was chedked.", "Warning",
            MessageBoxButtons::OK, MessageBoxIcon::Exclamation );
                     
                 }
                 if( checkBox2->Checked)
                 {
MessageBox::Show( "CheckBox2 was chedked.", "Warning",
            MessageBoxButtons::OK, MessageBoxIcon::Exclamation );
                     
                 }
             }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I don't know of any workaround, but then I have not done all that much CLR programming.

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

put something, such as getchar(), at the end of main() to prevent the window from closing.

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

The last example can't be compled with the express edition.

desimator55 commented: Helpful +0
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

First you will need a medical degree so that you know how to recognize a cataract when you see one. My eye specialist had to shine a bright light in my eyes in order to find them. Maybe you can do the same with a color picture -- maybe not. I don't know.

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

There are lots of different compilers for the same os too -- its called competition.

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

That code is already sending something on line 41.

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

>>i just thought i can treat the string array as a 2d char array
You can not do that because it isn't a 2d char array.

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

This is what I get when I run your program

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

um..
consider if in the main program, after the statement int k = a.getx();
we add one statements like cout <<k; what will that cout syntax print ? is 2 or 1 ?

The program will not execute because the compiler will not create the program. You will have to fix the error.

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

your program has a lot of other problems with those if statements. You can't just add digits to the strings like you are doing because there is no memory available for them. Use the += operator and remove [j] notation. Like this: arrconv[i]+='1';

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

If you are going to use new on line 16 then you have to delete[] it sometime later. Without that your program has a huge memory leak. Avoid that whole issue by not using pointers, declare the array on the stack. 30 strings is not going to cause stack overflow.

'g' and 'h' if statements appears twice.

A switch statement might be easier to code and read instead of all those if statements.

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

In the case of that function just call it like any other function that does not have the const keyword. The const keyword does nothing more than tell you that the function does not change anything. The following code will produce an error

class A
{
public:
    A() {x = 1;}
    int getx() const 
    {
        x = 2;  // <<< ERROR HERE
        return x;
    }
private:
    int x;
};

int main() 
{ 
    A a;
    int k = a.getx();
   return 0;
    
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Well the homework i have been given was to design and make a program that would convert binary code into a denary integer also backwards from denary to binary code.

I have done a bit of research through the internet, and i have seen some simple programs just by using text boxes and buttons to convert. But atm i do not know much about programming as i am a begginer, if anyone has any free time or have anything that could help me do my homework plz

Thanks ;)

Post your question in the appropriate language forum and people will help you with it.

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

That is not a new feature -- its been there for billions of years :)