Advertising (This ad goes away for registered users. You can Login or Register)

[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
Forum rules
Forum rule Nº 15 is strictly enforced in this subforum.
N6v7d8
Posts: 31
Joined: Fri May 25, 2012 6:01 am

Re: [Tutorial] Introduction to programming using C

Post by N6v7d8 »

Xian Nox wrote:
N6v7d8 wrote:Is there something missing?
gcc. It's not installed or not in the path.
Most likely it's just not in your path, so here's how to add it to your path: Right click on My Computer --> Properties --> Advanced System Settings --> Environmental variables --> double click Path, and append the following:

Code: Select all

;C:\MinGW\bin
This is the path to your MinGW install, so if it's on a different path, change accordingly. Also, the Path shouldn't contain any spaces, and the different paths on it are separated by a semicolon.
Also, it's much easier to just select all in your console window, and use the code tag here to paste it. To do so, right click on the command prompt, click select, select what you want, then press Enter to copy it.
Thank you very much TS! TT__TT

Image
Advertising
ReaperX
Posts: 470
Joined: Fri Jan 21, 2011 2:04 am
Location: Georgia

Re: [Tutorial] Introduction to programming using C

Post by ReaperX »

I Prefer AutoIt. :shock:
Advertising
PSP Information
PSP Model: Sold
PSP Motherboard:
PSP Firmware Version:
Make it idiot proof and someone will make a better idiot.
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: [Tutorial] Introduction to programming using C

Post by m0skit0 »

Huh? *Facepalm* Another typical Windows user that think he knows computers because he can use a GUI... Can you make an OS with AutoIt? Do you even know what an OS is? And FYI C is not (only) a scripting language. Inform yourself before saying such nonsense.
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: [Tutorial] Introduction to programming using C

Post by m0skit0 »

Xian Nox wrote:Right click on My Computer --> Properties --> Advanced System Settings --> Environmental variables --> double click Path, and append the following:

Code: Select all

;C:\MinGW\bin
And they say Windows is easy... :lol:
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
asgard20032
Posts: 186
Joined: Thu Jan 20, 2011 1:16 pm
Location: Milky Way, Solar system, Earth, North America, Canada, Québec..... In front of my computer

Re: [Tutorial] Introduction to programming using C

Post by asgard20032 »

And they say macintosh is easy...

On mac, not all standard program are available from command line. And from GUI, we can't change every setting. Mac = BSD, with lot of standard program we usually use removed, and from GUI, not many setting we can change, and some area of the directory hierarchy we can't even access even when we are root... So basically, Mac = complete desktop environment not very tweak-able, limiting end user's freedom to customize.

Only true OS are Unix(Excluding Mac) and GNU/Linux and GNU/Freebsd (Like Debian with BSD kernel). They are the only OS that allow user to do whatever they want with their OS(Especially with ArchLinux and Gentoo and Slackware, and most BSD).

I only tried Macintosh because it was a Unix, but was not happy.

Also, I found out that mac is not a good development environment. Fortunately, they keep GCC installed. But except that... bad integration with most of popular API, like GTK, because of X window... Some program not available, like HipHop PHP, a php compiler, is not available on mac. Because of the lack of customization, its also hard to make a server out of a mac, tweak every set up to get the maximum out of memory, disk access... We can not even boot in command line only, they impose us their horrible interface. And we can't use every programming language on mac. Also, most of the IDE either are not available, have bug, or just look horrible on mac (The look, it just don't fit well with the rest of the style of other window), so the only good IDE is Xcode, and I really don't like it.

Ok well, easy to shutdown, to power up, to log in, to open a internet browser, listen music, but beyond those, its not easy to do something more advanced out of a mac, so limited to basic task. But yeah, there is good program available for mac, like garage band, but beyond that, program not made by apple are not so good. Also, this happen quite often they break compatibility... From leopard to Snow leopard to Lion, happened so many time that program stopped working.

The only way to make good program on mac is by using objective-c, a horrible programming language. A language that only has use on Apple product. I won't learn that language that can't even be used on other system. Also, good luck with the file hierarchy, this is not even standardized... Library are not where they are suppose to be.

Trust us, you should go with a Linux Distribution or a BSD, and stop to pride windows, or mac.

For me, mac is a nerfed Unix. People think that mac is easier to use, but in reality, its not easier to use. A Linux distribution, well equipped (not a minimal installation) is easy as mac to use. It support almost all hardware with no need to install or configure driver, in most of the time. The desktop is clean, and its, in most of available distribution, ready to do programming.

Linux distribution I consider more easier to use than mac are: Ubuntu, Fedora, OpenSUSE, Linux Mint, Debian, Mandriva, Red Hat.
Many people say that Debian are for more intermediate user, but actually, i found out really easy to use. Equality with Ubuntu. I tried both, and I just can't find what is easier to use in Ubuntu. Its easy to use for normal user as long as you install a desktop environment. Else, its more for intermediate-advanced user.



Also, from what you already talked about AutoIt, we need to simulate keystroke and mouse click... Why complicate our life when we can simply make a call to another program to do the job or change a configuration file... In Perl and most other language, we simply make a shell command to use a program to do the job, and get the output. So much simpler to start/stop a server, than simulating keystroke...
Image
Tonakai
Posts: 594
Joined: Sun Aug 05, 2012 3:00 am
Location: United Kingdom.

Re: [Tutorial] Introduction to programming using C

Post by Tonakai »

Hi there, I'm having some issues with this and was hoping that someone would be kind enough to help me out? I installed Ubuntu to easier follow these tutorials, and some others I've found online, but I'm not experienced with it, at all and I'm running into some errors.

I installed the Build-Essential thing just fine through the Ubuntu Software Center, however, when I type CC into the Terminal as the tutorial states, I get this issue:

Code: Select all

tonakai@Tonakai:~$ cc
cc: fatal error: no input files
compilation terminated.
I also tried to use the apt-get install build-essential, and wouldn't work, giving me this error:

Code: Select all

tonakai@Tonakai:~$ apt-get install build-essential
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
So I logged in as root, and it simply updated the files I'd already downloaded from the Software Center, however again, CC gave the same error, so I assumed this would be okay, as the tutorial stated "no input files".

I moved on to writing the text into my text editor (using GEDIT) and saved it as foo.c, however I noticed that there was no temp$ folder, so I created one, and saved it into there. However, when compiling I got this:

Code: Select all

tonakai@Tonakai:~$ ~/temp$ cc -o foo foo.c
bash: /home/tonakai/temp$: Is a directory
I did attempt to make different directories (such as desktop then used ~/desktop), however I got the same issue while compiling. Okay, so that tells me nothing about whether or not it has compiled, but I guessed it would work, so I continued and recieved this:

Code: Select all

tonakai@Tonakai:~$ ~/temp$ ./foo
bash: /home/tonakai/temp$: Is a directory
Now from my understanding, it should print the text from the foo.c file in the terminal, rather than just telling me it's a directory.

What am I doing wrong here?
qwikrazor87
Guru
Posts: 2874
Joined: Sat Apr 21, 2012 1:23 pm
Location: The North Pole

Re: [Tutorial] Introduction to programming using C

Post by qwikrazor87 »

Hi Tonakai.
The "no input file" error is okay, it means that the compiler is installed.

In the terminal cd into the directory that you want to make your files, once you are there type into the terminal

Code: Select all

gedit foo.c
write in your code there then save it and exit gedit.
In the terminal type this,

Code: Select all

cc -o foo foo.c
If there are no errors then your code was successfully compiled.
Now type this in the terminal,

Code: Select all

./foo
You should see your code executed in the terminal.
PSP 2001 - TA-085 - 6.61 PRO-C2
PS Vita 3G - PCH-1101 - 3.65 HENkaku Ensō
Alcatel phone - Android 8.1.0
Laptop - Toshiba Satellite L305D-S5974 - Ubuntu 16.04 LTS
Tonakai
Posts: 594
Joined: Sun Aug 05, 2012 3:00 am
Location: United Kingdom.

Re: [Tutorial] Introduction to programming using C

Post by Tonakai »

Hey quikrazor, thank you very much for your quick response. Got it working now, thanks! :mrgreen:
m0skit0
Guru
Posts: 3817
Joined: Mon Sep 27, 2010 6:01 pm

Re: [Tutorial] Introduction to programming using C

Post by m0skit0 »

asgard20032 wrote:On mac, not all standard program are available from command line.
There's no such standard.
asgard20032 wrote:And from GUI, we can't change every setting.
This is also true for all other OS.
asgard20032 wrote:Mac = BSD
Better: Mac is BSD-based. BSD defines nothing about command line commands or GUI.
asgard20032 wrote:They are the only OS that allow user to do whatever they want with their OS
Each OS can offer a different set of experiences, and developers choose what they want to offer. Apple doesn't want to offer an OS that can do everything.
asgard20032 wrote:Some program not available
This is also true for all other OS.
asgard20032 wrote:its also hard to make a server out of a mac
Mac is not meant to be a server, so if you want a server, use another OS or virtualize it.
asgard20032 wrote:And we can't use every programming language on mac
Example?
asgard20032 wrote:its not easy to do something more advanced out of a mac, so limited to basic task
This is what Apple wants, it's not a problem for them. They know most people that use Mac are not developers.
asgard20032 wrote:objective-c, a horrible programming language
This is more your opinion than a fact.
asgard20032 wrote:A language that only has use on Apple product.
Because they invented it. Like .Net on Windows.
asgard20032 wrote:I won't learn that language that can't even be used on other system.
I don't understand. GCC compiles Objective-C.
asgard20032 wrote:good luck with the file hierarchy, this is not even standardized...
There's no such standard.
asgard20032 wrote:Library are not where they are suppose to be.
I don't understand. Where are they supposed to be?
asgard20032 wrote:you should go with a Linux Distribution or a BSD
I totally agree on this ;)
asgard20032 wrote:in most of available distribution, ready to do programming
Not true. E.g. Ubuntu does not install build-essentials by default.
asgard20032 wrote:Many people say that Debian are for more intermediate user
This is because Debian, as any other long living distro, was hard to use at first (like all other distros).
asgard20032 wrote:Equality with Ubuntu.
Ubuntu is based on Debian.

@Tonakai: glad you solved your problems ;)
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
Acid_Snake
Retired Mod
Posts: 3100
Joined: Tue May 01, 2012 11:32 am
Location: Behind you!

Re: [Tutorial] Introduction to programming using C

Post by Acid_Snake »

m0skit0 wrote:
asgard20032 wrote:objective-c, a horrible programming language
This is more your opinion than a fact.
he does have a point, just saying
Ubuntu does not install build-essentials by default.
I'm not sure but I think build-essentials is in fact inside the disc, but not installed by default (this was true for 7.10, I don't know the others)
asgard20032 wrote:Many people say that Debian are for more intermediate user
any operating system targeting desktop users can be for beginners, intermediate and advanced, it mostly depends on what you use the system for
m0skit0 wrote:
asgard20032 wrote:you should go with a Linux Distribution or a BSD
I totally agree on this ;)
I agree that I disagree on disagreeing with you
Locked

Return to “Programming and Security”