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

Lines 41, 42 and 43 use the wrong file description. Should be dir, not newemployyee

[edit]Oope! I didn't see the above when I posted this. Sorry for duplicating the answer [/edit]

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

Since you are using Visual Studio, place the cursor on one of the open {, press Ctrl+] and it will move the cursor to the matching closing }. In the case of your program you are missing two closing braces at the bottom of the code you posted.

Good coding and indentation practices helps a lot to quickly identify such errors.

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

Cross posting like this causes more problems than it's worth

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

My guess is no, at least not without hacking the data file and possibly the Windows registry entries. But you might ask the author of the game if there is an easier way to do it.

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

You don't need the switch statement inside the function, just inside main().
Delete lines 142-150 because that code is now in each of the functions that you created.

    void Binary2Decimal()
    {
        cout<<endl<<"[BINARY TO DECIMAL CONVERSION]"<<endl;
        cout<<endl;
        long b2,f2=1,d2=0;
        cout<<"Enter a Binary number: ";
        cout<<"nn";
        while(b2>0)
        {
           if((b2%10)==1)
           {
             d2=d2+f2;
           }
           b2=b2/10;
           f2=f2*2;
        }
        cout<<"Decimal equivalent is: "<<d2<<endl;
   }


    int main()
    {
    do{
    clrscr();
    cout<<"Conversion from any base to base 10"<<endl;
    cout<<endl;
    cout<<"a - Binary"<<endl;
    cout<<"b - Octal"<<endl;
    cout<<"c - Hexadecimal"<<endl;
    cout<<endl;
    cout<<"Select a value to be converted: ";
    cin>>value;
    switch(value){
    case 'a':
        Binary2Decimal();
        break;
    case 'b':
        Octal2Decimal();
        beak;
    case 'c':
        Hexa2Decimal();
        break;
    default:
        cout<<"Wrong input" << endl;
    }
    cout<<"Do you want to continue NUMBER CONVERSION?(y/n) ";
    cin>>answer;
    }
    while(answer == 'y');
    cout<<endl;
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This is cross post of the same thread in c++ forum?

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

It's very similar to how you coded main()

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


void Binary2Decimal() 
{

}

int main()
{


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

First create the empty functions what you need.
Next copy the code from the swith statement into the functions
Finally, replace the code in the swith statement with function calls.

How do you call a function? Very simply like this (which you have already posted):

Binary2Decimal();

john.kane.100483 commented: Can you make an example. Use my program us an example. +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

loops are the hardest thing.

Yes they do seem difficult when you are first learning -- But, like most everything else you do, a little practice helps clarify things in your head. Been there, and done that too.

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

You need to start a new loop on line 21, you can't reuse the same loop because the value of i counter is now beyond the bounds of the array. So just copy line 12 to between lines 20 and 21.

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

post code

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

use a loop very similar to the one I posted above except use cout instead of cin.

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

Start out by coding a very simple loop

int i;
for(i = 0; i < 5; i++)
{
   // code goes here
}

that goes on line 10, after students declaration. Now move lines 14-18 inside the loop and use the i counter to index into student array, like this:

cin >> students[i][0];

It would be a lot better to use a structure or a class, but you probably have not learned those yet. So arrays like you have them will work.

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

I don't know how to do it in Tubo C, but basically

get current corsor position
move the cursor back one character (probably with gotoxy() )
print a space at the current cursor position

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

That's true -- if you are coding with MFC in C++. AFAIK C# has no such similar library. The closest I can think of is DataGridView.

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

It doesn't remove the character from the window or change the cursor position because you never told it to do that. It only removes the charcter from passChar array. If you want to erase the character from the window then you need to add more code to do that.

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

This works ok too

int main()
    {
        Settings *s = new Settings;
        s->loadAndDrawFont();
        delete s;
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes

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

yes, 8 is the scancode for backspace, but it's in input, not in passChar[i].

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

The problem might be line 61 -- al_draw_text(...), I don't have that library installed so I couldn't call it.

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

See my previous post. passChar[i] will never contain the value of 8 because it hasn't been set yet.

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

line 27 is wrong.

else if (input == 8 && i > 1)

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

lines 3 and 4 of the code snippet untio posted are reversed -- have to zero out the current character before decrementing the value of i.

neyoibarra: repost current code.

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

line 30: should be --i; as previously mentioned, but -- be careful that the value of i does not go negative, such as pressing backspace too many times. So you might need something like this:

if( i > 1) { passChar[i] = '\0'; --i;}

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

The problem must be soemthing else in the program that has corrupted stack or program memory. The code below works ok for me

#include<string>
#include<vector>
#include<iostream>

using namespace std;

class Settings
{
private:
    vector<string>board;
protected:
public:
    Settings();

    bool loadAndDrawFont();
};



Settings::Settings()
{
    board.push_back("050106007");
    board.push_back("620054090");
    board.push_back("000908002");
    board.push_back("300000568");
    board.push_back("080605020");
    board.push_back("546000009");
    board.push_back("700502000");
    board.push_back("030840016");
    board.push_back("800301040");
}

bool Settings::loadAndDrawFont()
{

    for (int i = 0; i < 9; i++)
    {
        for (int j = 0; j < 9; j++)
        {
            if (board[i][j] == ('1'))//this is the line thats the problem
            {
                cout << board[i][j] << '\n';
            }
        }
    }
    return true;
}
    int main()
    {
        Settings s;
        s.loadAndDrawFont();
    }
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can add any other columns you want, and that has already been posted 3 times. I don't think there is any need for the group by clause because there will be only one result row.

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

Here is a related article you might find helpful.

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

Google does many good things for you. Study this link

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

That's not a question, it's simply a statement of the program you have to write. -- we don't do homework for people. You write the program then ask specific question(s) about what you don't understand.

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

See your other thread here.

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

5ec5c6cffeddfadcd44f0b599daf0631

This post has no text-based content.
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Link (google does wonders for answering homework problems)

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

Do you know SQL (Structured Query Language)?. It doesn't matter what programming language you use, all of them have to use SQL statements in order to accomplish the tasks you are asking about.

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

google for c++ keywords and you will find this article

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

Simple SQL statement

SELECT name,COUNT(age) as AGECOUNT FROM table WHERE age = 14
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I have a tablet for a couple years now -- almost complete waste of money. The only thing I use it for is to play a few games on occasion. One time I thought I could set the tablet up so that I could watch TV on it through my TV provider -- paid a few dollars to get the TV receiption rebroadcase onto my wifi then receive the wifi signal to the tablet -- it worked -- but it was sooo slow that it was nearly unwatchable. Good idea, but it's just not fast enough.

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

These are laser beam images

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

My PC has a lot of external devices connected to it, I don't see how a tablet could possibly do that. The tablet I have has only one port -- to tether to a PC or recharger.

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

AFAIK there is no such library. I worked on a project which included RBAC and all we did was (1) define what class of users have access to what program features. (2) When a user logged into the program (needed user name and password) the program looked up the roles database and disabled all program features which the user did not have permisions. Program menus may change at runtime to accommodate the roles.

This is highly application dependent, so I don't know how a general RBAC library could exist.

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

Do you have a question?

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

Set the default browser to Firefox and your program will probably work.

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

You're right Suzie999, there is no need to convert from char to hex -- char is already hex. Whether it is int or hex all depends on how you want to display it to us humans. It's all the same to computers. Line 14 could just as easily be written like this:

P6 = greeting[i] >> 4;

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

Freezing rain and sleet this morning, snow coming tonight.

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

line 15 of the original post increments ptr within the loop, which is ok. But ptr is not reset back to the beginning of the array before the next loop starts on line 18. On line 19 ptr is beyond the end of the array so (ptr+i) is always invalid.

Fix the problem by copying line 9 to a new line just before line 18.

Then ptr = &arr[0] should be written as ptr = arr

It doesn't really matter one way or the other, both are correct and the compiler won't care which way you code it.

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

Make the two friend functions friends of CustomString, not LongInteger. In main(), don't use pointers.

class CustomString
{
public:
    CustomString(std::string s) { SetStr(s); }
    CustomString();
    void SetStr(std::string s) { vec.push_back(s); }
    bool friend operator!= (CustomString& str1, CustomString& str2);
    bool friend operator== (CustomString& str1, CustomString& str2);

    std::vector<string> vec;
};




bool operator== (CustomString& str1, CustomString& str2)
{
    if (str1.vec.size() != str2.vec.size())
    {
        return false;
    }
    std::vector<string>::iterator s2 = str2.vec.begin();

    bool result = true;

    for (std::vector<string>::iterator s = str1.vec.begin(); s != str1.vec.end(); ++s)
    {



        if (*s2 != *s)
        {
            cout << *s2 << ' ' << *s << endl;

            result = false;
        }


        ++s2;
    }

    return result;
}


bool operator!= (CustomString& str1, CustomString& str2)
{
    return str1 == str2 ? false : true;
}

int main()
{
    CustomString str("helloworld");


    CustomString str2("helloworld");

    str.SetStr("One");
    str2.SetStr("Two");

    if(str != str2)
    {
        cout << "everything is ok" << endl;
    }
    else
    {
        cout << "something is wrong" << endl;
    }

    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Like I said, that won't compile for the reason you just posted. In your program one of the parameters to the friend function must be a reference to LargeInteger class. If that is not needed, then don't make it a friend function.

So I need to use *&, what's the name of such construct, pointer address, and how is it different from a pointer(

The & makes it a reference to a pointer, something similar to **. Since str1 and str2 are both pointers, you can do away with the & operator and just pass the pointers.

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

w3schools are not video tutorials, but worthwhile reading anyway.

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

I looked over the options in Visual Studio 2013 and, as far as I can tell, only MFC programs can be statically linked to the MFC dlls. None of the other program types have that option.

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

if (str != str2)

Since the memory for str and str2 are allocated at runtime they two address will never be the same. Lines 10 and 14 are reversed, line 8 will always be true so there is nothing wrong.

Since str1 and str2 are really pointers, here is how to write the code

class CustomString
{
public:

    std::vector<string> vec;
};



class LongInteger
{

    friend bool operator== (CustomString *&str1, CustomString *&str2);
    friend bool operator!= (CustomString *&str1, CustomString *&str2);


public:


private:
    vector<string> vec;

};

bool operator!= (CustomString *&str1, CustomString *&str2)
{
    std::vector<string>::iterator s2 = str2->vec.begin();



    for (std::vector<string>::iterator s = str1->vec.begin(); s != str1->vec.end(); ++s)
    {


*
        if (*s2 == *s)
        {
            cout << *s2 << *s << endl;

            return false;
        }


        ++s2;
    }

    return true;
}

int main()
{
    CustomString *str = new CustomString("helloworld");

    CustomString *str2 = new CustomString("helloworld");


    if (str != str2)
    {
        cout << "everything is ok" << endl;
    }
    else
    {
        cout << "something is wrong" << endl;
    }

    return 0;
}

That still won't compile because the two operator lines in class LongInteger are incorrect.

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

Insert a new line between lines 25 and 26 to print out the value of ch so that you can see what's happening.