PSP TuneRandom Homebrew: PSP Tune
PSPTune is a guitar tuner for the Sony PSP with an integrated text viewer for viewing tablature.
Friends: Coding 'n Cracking - Nymphaea - PS3 Forum - darkforestgroup - daxhordes.org - Tgames - coldbird - gopsp.it - pspstation.org - prometheus - hgoel.info - MakeSmartTV - ps vita

[Tutorial] Introduction to programming using C

Discuss about your favorite (gaming...or not) devices here. The most popular ones will end up getting their own categories
Programming discussions for your favorite Device

Re: [Tutorial] Introduction to programming using C (I)

Postby waratte » Sun May 15, 2011 10:54 pm

frank wrote:irfanhb7 i bet ur on windows and that the cmd prompt just blinks right
well u can use getch to have it stop till u press a key
but that has nothing to do with return, u still need return

Actually, you don't have to return anything if you specify your function as "void".
irfanhb7 wrote:Oh ! You posted a tutorial.
I have one question and pls don't get angry.
Can we use void main() instead of int main and getch() instead of return 0 ?

Answer to question 1: http://www.gidnetwork.com/b-66.html
waratte
 
Posts: 4066
Joined: Wed Oct 20, 2010 12:03 am

Re: [Tutorial] Introduction to programming using C (I)

Postby frank » Sun May 15, 2011 11:02 pm

i knew that waratte :]
just he needs it for int main
well actually the app will still work
but its a crime to not have return in int main
ill betcha m0skit0 can explain why
Sig shrink!
PSP 2000 6.60 ME-1.8
G1 - Super D 1.11
Samsung Galaxy Tab 2 GT-P5113 - CyanogenMod 10
PC - Windows 7 - P4 3.20ghz HT - 3 gb 756 mb RAM - ATI Radeon x600
Cardboard box server - Ubuntu Server :D - AMD Athlon XP 3000+ - 512mb RAM
frank
 
Posts: 545
Joined: Wed Mar 23, 2011 5:15 am
Location: northwest usa

Re: [Tutorial] Introduction to programming using C (I)

Postby waratte » Sun May 15, 2011 11:07 pm

frank wrote:i knew that waratte :]
just he needs it for int main
well actually the app will still work
but its a crime to not have return in int main
ill betcha m0skit0 can explain why

Here's some more information on the subject:
http://users.aber.ac.uk/auj/voidmain.shtml
waratte
 
Posts: 4066
Joined: Wed Oct 20, 2010 12:03 am

Re: [Tutorial] Introduction to programming using C (I)

Postby ASKidwai » Mon May 16, 2011 3:35 am

Oh, OK.
Thanks for the clarification but this code works with GCC but won't work with CC. Here is the code
Code: Select all
//Slightly modded Hello World

#include <stdio.h>

int main()
{
   printf("I hate the ; at the end. \n Lua really did teach bad habits \n");
   return(0);
}

It makes an executable with GCC but CC shows this
Code: Select all
cc goodbye -o bye
goodbye: In function `_start':
(.text+0x0): multiple definition of `_start'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o:(.text+0x0): first defined here
goodbye:(.rodata+0x0): multiple definition of `_fp_hw'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o:(.rodata+0x0): first defined here
goodbye: In function `_fini':
(.fini+0x0): multiple definition of `_fini'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crti.o:(.fini+0x0): first defined here
goodbye:(.rodata+0x4): multiple definition of `_IO_stdin_used'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o:(.rodata.cst4+0x0): first defined here
goodbye: In function `__data_start':
(.data+0x0): multiple definition of `__data_start'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crt1.o:(.data+0x0): first defined here
goodbye: In function `__data_start':
(.data+0x4): multiple definition of `__dso_handle'
/usr/lib/gcc/i486-linux-gnu/4.4.3/crtbegin.o:(.data+0x0): first defined here
goodbye: In function `_init':
(.init+0x0): multiple definition of `_init'
/usr/lib/gcc/i486-linux-gnu/4.4.3/../../../../lib/crti.o:(.init+0x0): first defined here
/usr/lib/gcc/i486-linux-gnu/4.4.3/crtend.o:(.dtors+0x0): multiple definition of `__DTOR_END__'
goodbye:(.dtors+0x4): first defined here
collect2: ld returned 1 exit status


EDIT: Don't you have to put
Code: Select all
return 0;
in a parenthesis like this
Code: Select all
return(0);
?
Image
Image
Image
Image
ASKidwai
 
Posts: 1411
Joined: Mon Jan 10, 2011 7:42 am
Location: 'Ere and There

Re: [Tutorial] Introduction to programming using C (I)

Postby m0skit0 » Mon May 16, 2011 6:53 am

frank wrote:irfanhb7 i bet ur on windows and that the cmd prompt just blinks right
well u can use getch to have it stop till u press a key
but that has nothing to do with return, u still need return

You're right, but as stated on the OP, no discussion about Windows-related stuff, so please keep this clean.

ASKidwai wrote:Thanks for the clarification but this code works with GCC but won't work with CC.

Quite strange. Use gcc then.

ASKidwai wrote:EDIT: Don't you have to put

return 0;

in a parenthesis like this

return(0);

Nope, you don't have to. You can do it if you like it better, but it's not mandatory.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4783
Joined: Mon Sep 27, 2010 6:01 pm

Re: [Tutorial] Introduction to programming using C (I)

Postby ASKidwai » Mon May 16, 2011 6:56 am

m0skit0 wrote:Quite strange. Use gcc then.

I do...

m0skit0 wrote:Nope, you don't have to. You can do it if you like it better, but it's not mandatory.

OK, then

BTW, isn't C a middle-level language?
Image
Image
Image
Image
ASKidwai
 
Posts: 1411
Joined: Mon Jan 10, 2011 7:42 am
Location: 'Ere and There

Re: [Tutorial] Introduction to programming using C (I)

Postby irfanhb7 » Mon May 16, 2011 6:58 am

Going to double boot 7 and linux ,will it cause any problems?? because last time I double booted xp on 7 I had a lot of problems.
BTW which version of linux shall I buy ?
Languages I know : C , C++ & Java
Image
Boy : There is something wrong with my phone.
Girl : What ?
Boy: It don't have your Phone Number.
Image
irfanhb7
 
Posts: 836
Joined: Wed Jan 26, 2011 2:46 pm
Location: In your nightmares

Re: [Tutorial] Introduction to programming using C (I)

Postby ASKidwai » Mon May 16, 2011 7:08 am

irfanhb7 wrote:Going to double boot 7 and linux ,will it cause any problems?? because last time I double booted xp on 7 I had a lot of problems.
BTW which version of linux shall I buy ?

Depends on how you install it. I used to quadriple between Ubuntu , Fedora, Kubuntu and Windows 7 without any problems.

Linux is free :D
Image
Image
Image
Image
ASKidwai
 
Posts: 1411
Joined: Mon Jan 10, 2011 7:42 am
Location: 'Ere and There

Re: [Tutorial] Introduction to programming using C (I)

Postby irfanhb7 » Mon May 16, 2011 7:12 am

From where can I get it because no one in my area uses linux.
Languages I know : C , C++ & Java
Image
Boy : There is something wrong with my phone.
Girl : What ?
Boy: It don't have your Phone Number.
Image
irfanhb7
 
Posts: 836
Joined: Wed Jan 26, 2011 2:46 pm
Location: In your nightmares

Re: [Tutorial] Introduction to programming using C (I)

Postby ASKidwai » Mon May 16, 2011 7:16 am

Image
Image
Image
Image
ASKidwai
 
Posts: 1411
Joined: Mon Jan 10, 2011 7:42 am
Location: 'Ere and There

PreviousNext

Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest