Seite 48 von 340 ErsteErste ... 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 98 148 ... LetzteLetzte
Zeige Ergebnis 1.411 bis 1.440 von 10174

C/C++ Programming Help Thread

This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; I'm uhh... Begining this C++ stuff. Need some help here. Just making a little thingy to see what I know. ...

  
  1. #1411
    QJ Gamer Blue
    Points: 6.041, Level: 50
    Level completed: 46%, Points required for next Level: 109
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Missouri
    Beiträge
    451
    Points
    6.041
    Level
    50
    Downloads
    0
    Uploads
    0

    Standard

    I'm uhh... Begining this C++ stuff. Need some help here. Just making a little thingy to see what I know. :\

    #include <iostream.h>
    int main() {
    int theYear = 2006;
    return 0;
    }
    int main() {
    int myBirthYear = 1992;
    return 0;
    }
    int main() {
    int myAge = << theYear - myBirthYear << endl;
    cout << "My age is " << myAge << endl;
    return 0;
    }
    -= Double Post =-
    Oh. And I don't understand the compiler errors on Dev-Cpp... :\


    Geändert von Cheez Pirate (10-19-2006 um 06:15 PM Uhr) Grund: Automerged Doublepost

  2. #1412
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    #include <iostream.h>
    int main() {
    int theYear = 2006;
    int myBirthYear = 1992;
    int myAge = << theYear - myBirthYear << endl;
    cout << "My age is " << myAge << endl;
    return 0;
    }
    I know nothing of C++. But from coding C on the PSP, something tells me it should be more like that.

  3. #1413
    QJ Gamer Blue
    Points: 6.041, Level: 50
    Level completed: 46%, Points required for next Level: 109
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Missouri
    Beiträge
    451
    Points
    6.041
    Level
    50
    Downloads
    0
    Uploads
    0

    Standard

    Wow. I just realized how stupid I am. Even though it doesn't work. Need more help please lol.
    -= Double Post =-
    I think my only problem is subtracting. I didn't know how so I took a guess. Someone tell me how to subtract?
    Geändert von Cheez Pirate (10-19-2006 um 06:24 PM Uhr) Grund: Automerged Doublepost

  4. #1414
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Cheez Pirate
    Wow. I just realized how stupid I am.
    its ok. my first program in C was similar to this:


    Code:
    int 5;
    
    void main(x)
    {
    
    print("what is int?" " int is int")
    
    end
    
    }

    BTW, i got my problem fixed.
    --------------------------------------------------------------------------------------

  5. #1415
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    #include <iostream>
    using namespace std;
    
    int main () {
      int currentYear, myBirthYear;
      int myAge;
      currentYear = 2006;
      myBirthYear = 1992;
      myAge = currentYear - myBirthYear;
      cout << myAge;
      return 0;
    }
    Try that.

  6. #1416
    QJ Gamer Blue
    Points: 6.041, Level: 50
    Level completed: 46%, Points required for next Level: 109
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Missouri
    Beiträge
    451
    Points
    6.041
    Level
    50
    Downloads
    0
    Uploads
    0

    Standard

    Oh. Ok, hang on. By the way. What's the difference between C, and C++?

  7. #1417
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Cheez Pirate
    Oh. Ok, hang on. By the way. What's the difference between C, and C++?
    I edited the code because I seen a mistake. So if it doesn't work, try the new code. And the only only difference between them is syntax. It's the only difference between all languages. They all work the same way. You just have to know the 'words' the language should be written in.

  8. #1418
    QJ Gamer Blue
    Points: 6.041, Level: 50
    Level completed: 46%, Points required for next Level: 109
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Missouri
    Beiträge
    451
    Points
    6.041
    Level
    50
    Downloads
    0
    Uploads
    0

    Standard

    Thanks. That worked! And I understand it too. Thanks a lot!

  9. #1419
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    I think the problem was that you forgot using namespace std;. But as I said, I'm no expert.

  10. #1420
    QJ Gamer Blue
    Points: 6.041, Level: 50
    Level completed: 46%, Points required for next Level: 109
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Missouri
    Beiträge
    451
    Points
    6.041
    Level
    50
    Downloads
    0
    Uploads
    0

    Standard

    :o Also. Is there a main loop? I run it and it disapears right away.

  11. #1421
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    I don't know. I just modified this code from a tutorial.

    // operating with variables

    #include <iostream>
    using namespace std;

    int main ()
    {
    // declaring variables:
    int a, b;
    int result;

    // process:
    a = 5;
    b = 2;
    a = a + 1;
    result = a - b;

    // print out the result:
    cout << result;

    // terminate the program:
    return 0;
    }

  12. #1422
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Cheez Pirate
    :o Also. Is there a main loop? I run it and it disapears right away.

    do this:

    Code:
    int main() {     // your main function //
    
    while (1) {
    
    // the printing stuff here//
    
    sceDisplayWaitVblankStart();
    flipScreen();
    }
    
    sceKernelSleepThread(); 
    return 0;
    
    }
    that basically says, "wait forever." :)
    --------------------------------------------------------------------------------------

  13. #1423
    QJ Gamer Blue
    Points: 6.041, Level: 50
    Level completed: 46%, Points required for next Level: 109
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Missouri
    Beiträge
    451
    Points
    6.041
    Level
    50
    Downloads
    0
    Uploads
    0

    Standard

    Ok. Guess I gotta get rid of "return 0;"
    -= Double Post =-
    Or that lol.
    Geändert von Cheez Pirate (10-19-2006 um 06:42 PM Uhr) Grund: Automerged Doublepost

  14. #1424
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Propel
    I don't know. I just modified this code from a tutorial.

    // operating with variables

    #include <iostream>
    using namespace std;

    int main ()
    {
    // declaring variables:
    int a, b;
    int result;

    // process:
    a = 5;
    b = 2;
    a = a + 1;
    result = a - b;

    // print out the result:
    cout << result;

    // terminate the program:
    return 0;
    }
    propel, stop leading him towards computer C++. i understand that your trying to help, but comp. and psp stuff is very different. for one, in psp, you dont need to put:

    Code:
    using namespace std
    and you need a loop, just like in lua.
    --------------------------------------------------------------------------------------

  15. #1425
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Grimfate126
    do this:

    Code:
    int main() {     // your main function //
    
    while (1) {
    
    // the printing stuff here//
    
    sceDisplayWaitVblankStart();
    flipScreen();
    }
    
    sceKernelSleepThread(); 
    return 0;
    
    }
    that basically says, "wait forever." :)
    He's coding for the PC.

  16. #1426
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Propel
    He's coding for the PC.

    then why is it in this section?
    --------------------------------------------------------------------------------------

  17. #1427
    I'm Baaaack!
    Points: 17.067, Level: 83
    Level completed: 44%, Points required for next Level: 283
    Overall activity: 52,0%

    Registriert seit
    May 2006
    Ort
    Nowhere
    Beiträge
    2.186
    Points
    17.067
    Level
    83
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Grimfate126
    then why is it in this section?
    Because it's the C/C++ Development thread. Maybe he's practicing coding for the PSP.

  18. #1428
    QJ Gamer Blue
    Points: 6.041, Level: 50
    Level completed: 46%, Points required for next Level: 109
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Missouri
    Beiträge
    451
    Points
    6.041
    Level
    50
    Downloads
    0
    Uploads
    0

    Standard

    Ya. I'm using it on both.
    -= Double Post =-
    Like learning both at the same time. Functions for PSP, and comp.
    Geändert von Cheez Pirate (10-19-2006 um 06:49 PM Uhr) Grund: Automerged Doublepost

  19. #1429
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Cheez Pirate
    Ya. I'm using it on both.
    -= Double Post =-
    Like learning both at the same time. Functions for PSP, and comp.
    ok. im just warning you that you may get confused. try to learn one thing. then use it for another. (ur choice.)
    --------------------------------------------------------------------------------------

  20. #1430
    QJ Gamer Blue
    Points: 6.041, Level: 50
    Level completed: 46%, Points required for next Level: 109
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    Missouri
    Beiträge
    451
    Points
    6.041
    Level
    50
    Downloads
    0
    Uploads
    0

    Standard

    lol ok. Well I saved the PSP main loop in a txt doc. Now I need the loop for the computer if there is one. Coz when I run it. It still shuts itself off after like a milisecond.

  21. #1431
    Your Fate is Grim...
    Points: 11.640, Level: 70
    Level completed: 98%, Points required for next Level: 10
    Overall activity: 0%

    Registriert seit
    Oct 2005
    Beiträge
    2.269
    Points
    11.640
    Level
    70
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Cheez Pirate
    lol ok. Well I saved the PSP main loop in a txt doc. Now I need the loop for the computer if there is one. Coz when I run it. It still shuts itself off after like a milisecond.

    i dont know much about comp c++. use google.
    --------------------------------------------------------------------------------------

  22. #1432
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    Just put system("PAUSE"); right before the return 0;

    Oh, and you don't have to put using namespace std; you simply can write std::cout, std::cin ... instead.


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  23. #1433
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Bronx
    Ok, youresame told me to tell you this
    >
    Not sure what it means, do you?....
    No Idea, but tell him this: < !!

    Zitat Zitat von homer
    It's faster to blit the arrows separately.
    Seriuosly? Why is that?

  24. #1434
    QJ Gamer Green
    Points: 6.920, Level: 54
    Level completed: 85%, Points required for next Level: 30
    Overall activity: 0%

    Registriert seit
    May 2006
    Ort
    Programming or Farming Mudkips
    Beiträge
    657
    Points
    6.920
    Level
    54
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Cheez Pirate
    Ya. I'm using it on both.
    -= Double Post =-
    Like learning both at the same time. Functions for PSP, and comp.
    I wouldn't do that. That's just settign yourself up towards failure. Just learn c. And I really wouldn't recommend learning on the pc, seeing as it's actually easier to code on the psp then the pc. :P
    Current Project: Citrus

  25. #1435
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Zettablade: That is a matter of opinion. I find it a hell of a lot easier to program something with C++ then C. Strip away all the libraries and I pick C++ with classes, strict type safety, const correctness and template metaprogramming over C structs and macros any day of the week.

    I also disagree about learning straight away on a PSP/DS/any hardware platform. Trying to get your head round the SDK/toolchain AND learning how to program at the same time can be extremely difficult to do for a new programmer. However, I agree that you should only develop for one platform then move on to the next.
    Geändert von yaustar (10-20-2006 um 04:28 AM Uhr)

  26. #1436
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Lukeson
    Seriuosly? Why is that?
    I think that's what youresam tried to tell you too.

    The reason it's faster is because it doesn't have to go through as many pixels. Just think about it, the large image contains 480*272 pixels, while the arrows contain like 5*5+5*5+5*5 ...


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  27. #1437
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    i c... (even though the image is only 5*260, still true)

  28. #1438
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    In addition, you are using less memory to store the image of one arrow.

  29. #1439
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Getting an error google doesn't have an answer for:

    I got a round fuction from http://www.cs.tut.fi/~jkorpela/round.html . I included <limits.h> as written on the page. The error I get is
    main.c:(.text+0x2c): undefined reference to `assert'
    main.c:(.text+0x4c): undefined reference to `assert'
    The code is
    Code:
    long round(double x) {
    	assert(x >= LONG_MIN-0.5);
    	assert(x <= LONG_MAX+0.5);
    	if (x >= 0)
    		return (long) (x+0.5);
    	return (long) (x-0.5);
    }

  30. #1440
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    You need to #include <assert.h> where you use the function assert. (#include <cassert> if you are using C++).


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 09:15 PM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .