Jump to content

I Need Some Motivation...


Recommended Posts

To start programming again. Ever since the whole event regarding Ashbrook Prime, I've lost the will.

 

 

So, any projects or challenges anyone can think of? Please keep it simple, and no OpenGL (my mind is still scarred).

Share this post


Link to post
Share on other sites

  • Replies 28
  • Created
  • Last Reply

Top Posters In This Topic

Lol, I said simple stuff. However, once I can get some file deleting source code... *insert much evil laughter here*

 

 

EDIT: I can't even write code that compiles right...

 

#include <iostream>
#include <stdlib.h>

using namespace std;

int daTionOfFunc(); //Prototype

int *pPointarThatPoints;

int theNumbar;

int main(void)

{
    cout << "Enter a numbar!\n\n>";
    cin >> theNumbar;
    
    *pPointarThatPoints = &theNumbar;
    
    daTionOfFunc(*pPointarThatPoints);
    
    return 0;
    
}


int daTionOfFunc(int one);

{
    cout << "\n\nYou entered: " << one;
    cout << "\n\n\n"
    
    system("pause");
 
  return one;   
}

Share this post


Link to post
Share on other sites

Lol, I said simple stuff. However, once I can get some file deleting source code... *insert much evil laughter here*

EDIT: I can't even write code that compiles right...

 

#include <iostream>
#include <stdlib.h>

using namespace std;

int daTionOfFunc(int); //Prototype

int *pPointarThatPoints;

int theNumbar;

int main(void)

{
    cout << "Enter a numbar!\n\n>";
    cin >> theNumbar;
    
    *pPointarThatPoints = &theNumbar;
    
    daTionOfFunc(*pPointarThatPoints);
    
    return 0;
    
}


int daTionOfFunc(int one);

{
    cout << "\n\nYou entered: " << one;
    cout << "\n\n\n"
    
    system("pause");
 
  return one;   
}

505701[/snapback]

 

Despite it not working/compiling, again, if it makes you feel better, I could never have even written that much at your age :P

 

If you want it to compile it looks to me that..

  • You've forgotted a ; at the end of cout << "\n\n\n" in daTionOfFunc()
  • *pPointarThatPoints = &theNumbar; looks wrong. That would be setting the value of the pointer to the address of the number, since you've declared pPointarThatPoints as a pointer, so the * would be a... dereference. I think it should be pPointarThatPoints = &theNumbar;
  • You have an un-needed ; in the declaration of int daTionOfFunc(int one); See, at the end there? :)
  • The function prototype for daTionOfFunc() is wrong. You forgot to put the int in there. Should be int daTionOfFunc(int);

Not bad though. It looks like you're getting the hang of pointers :) You used the pointer correctly to pass in to the function, well, you dereferenced the pointer to pass the number instead of the address at least ;)

 

It may be better to declare the parameter as a pointer for large data or a structure and pass the address. But for numbers, it doesn't matter too much, unless you want to change the number in that function and have it also change outside of that function :)

 

Something like...

 

#include <iostream>
#include <stdlib.h>

using namespace std;

int daTionOfFunc(int *); //Prototype

int *pPointarThatPoints;

int theNumbar;

int main(void)

{
    cout << "Enter a numbar!\n\n>";
    cin >> theNumbar;

    pPointarThatPoints = &theNumbar;

       cout << "main()" << endl;
       cout << "Number is now: " << theNumbar << endl;
       cout << "Pointer value is now: " << *pPointarThatPoints << endl;

    daTionOfFunc(pPointarThatPoints);

       cout << "main()" << endl;
       cout << "Number is now: " << theNumbar << endl;
       cout << "Pointer value is now: " << *pPointarThatPoints << endl;

    return 0;

}


int daTionOfFunc(int *one)

{
    cout << "\n\nYou entered: " << *one;
    cout << "\n\n\n";

       cout << "daTionOfFunc()" << endl;
       cout << "variable one = 2" << endl;
*one = 2;

    system("pause");

  return *one;
}

 

(mrboo|bone)/home/mrboo$ ./kb
Enter a numbar!

>1
main()
Number is now: 1
Pointer value is now: 1


You entered: 1


daTionOfFunc()
variable one = 2

main()
Number is now: 2
Pointer value is now: 2

 

The difference here is that if you now change the value of "one" in daTionOfFunc(), because it's an address pointing to theNumbar in main(), the number gets changed there too. As is demonstrated by the above. Where as if you just pass the number by value, you can change it in daTionOfFunc() and it'll still be the same value in main()

 

#include <iostream>
#include <stdlib.h>

using namespace std;

int daTionOfFunc(int); //Prototype

int *pPointarThatPoints;

int theNumbar;

int main(void)

{
    cout << "Enter a numbar!\n\n>";
    cin >> theNumbar;

    pPointarThatPoints = &theNumbar;

       cout << "main()" << endl;
       cout << "Number is now: " << theNumbar << endl;
       cout << "Pointer value is now: " << *pPointarThatPoints << endl;

    daTionOfFunc(*pPointarThatPoints);

       cout << "main()" << endl;
       cout << "Number is now: " << theNumbar << endl;
       cout << "Pointer value is now: " << *pPointarThatPoints << endl;

    return 0;

}


int daTionOfFunc(int one)

{
    cout << "\n\nYou entered: " << one;
    cout << "\n\n\n";


       cout << "daTionOfFunc()" << endl;
       cout << "variable one = 2" << endl;
one = 2;

    system("pause");

  return one;
}

 

(mrboo|bone)/home/mrboo$ ./kb
Enter a numbar!

>1
main()
Number is now: 1
Pointer value is now: 1


You entered: 1


daTionOfFunc()
variable one = 2

main()
Number is now: 1
Pointer value is now: 1

 

However, I think I blabbered and you probably wont get any of that :lol:

 

I know what you mean by needing motivation though. I do too.. I've been coding up crap in PHP + MySQL the past couple of days. That was quite fun.

 

As for ideas of something to do. Not managed to do that encoding text thing yet? ;) That was probably quite hard for something to start with though.

 

Hmm... the only simple assignment I can remember from first year of Uni was a little guess the number game. Maybe you could do something like that? Make a random number, say from 1 to 10, and .. just take user guesses and say if the number was too big, too small, or correct. You might have difficulty levels like easy, medium, hard and insane... which... increase the random number range? Or.... limit the amount of guesses you have? Say 10 guesses on easy ( which means you should always win, so maybe 7 ;) ), 5 on medium and 3 on hard and... 1 on insane? :)

 

Just an idea..

Share this post


Link to post
Share on other sites

I can see it now...

 

if (numberGuessed != theNumber)

{

    cout << "YOU SUCK! GET THE HELL OUT!\n\n\n\n\nPlease try again: ";
    cin >> numberGuessed;

505901[/snapback]

 

:lol: a possibility :)

 

But... it's somewhere to start and it's not toooo difficult :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×
×
  • Create New...