LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-29-2002, 03:59 AM   #1
Bernhard
LQ Newbie
 
Registered: Jan 2002
Location: Bielefeld/Germany
Distribution: SuSE 7.3 German
Posts: 26

Rep: Reputation: 15
Red face Careful! Newbie question! :)


Hello friends,

I want to make my own C-Programs. Small ones!!!

Just like

main()
{ printf("Hello!") }

In which steps can I compile and execute my
small C-sweets??

Yours,
Bernhard
 
Old 01-29-2002, 04:11 AM   #2
dorward
Member
 
Registered: Sep 2001
Distribution: Gentoo
Posts: 760

Rep: Reputation: 31
dd@hermes:~> cat > test.c
#include <stdio.h>

main()
{ printf("Hello!"); }

dd@hermes:~> gcc -o test test.c
dd@hermes:~> chmod +x test
dd@hermes:~> ./test
Hello!
 
Old 01-29-2002, 12:03 PM   #3
bripage
Member
 
Registered: Jan 2002
Location: Moorpark
Distribution: SLACK 8!
Posts: 230

Rep: Reputation: 30
why you using cat for that? I thought that cat was used to view a file and not have the ability to make changes to the file. Is htat write?
 
Old 01-29-2002, 12:08 PM   #4
dorward
Member
 
Registered: Sep 2001
Distribution: Gentoo
Posts: 760

Rep: Reputation: 31
cat takes input from a file or stdin and outputs it on stdout.

The ">" operator redirects stdout from the console to a file.

Its a convienient way to get a little bit of text in to a file or to give examples involving the contents of files.
 
Old 01-29-2002, 12:15 PM   #5
bripage
Member
 
Registered: Jan 2002
Location: Moorpark
Distribution: SLACK 8!
Posts: 230

Rep: Reputation: 30
blah blah blah?!?
Ok noob here just said what my limited exsiting knowledge was telling me....

So you can, use cat to take a file and then have it make a new file containing whatever changes you wanted to make? And what it stdin and stdout, becuase this sounds like valuable info.

 
Old 01-29-2002, 12:32 PM   #6
dorward
Member
 
Registered: Sep 2001
Distribution: Gentoo
Posts: 760

Rep: Reputation: 31
Well... making changes with cat by itself is very difficult.

Generally you would run it through a stream editor.

e.g.

cat myfile | sed s/this/that/ > newfile

The pipe (|) redirects stdout to the stdin of an other program, sed then replaces all instances of "this" with the word "that" and outputs it to stdout, the ">" then redirects stdout to a file called "newfile".

stdin and stdout are standard input and standard output, and are generally the keyboard and the screen respectively.

>> appends, > overwrites so you could use cat to add stuff to a file.

cat firstfile secondfile > newfile

would create a new file which was the first file followed by the second file.

cat secondfile >> firstfile

would add secondfile to the end of firstfile.
 
Old 01-29-2002, 04:38 PM   #7
bripage
Member
 
Registered: Jan 2002
Location: Moorpark
Distribution: SLACK 8!
Posts: 230

Rep: Reputation: 30
ahhh Ic now. I shall add this to my knowlegde of Linux. Thank you.
 
Old 01-31-2002, 05:29 AM   #8
Bernhard
LQ Newbie
 
Registered: Jan 2002
Location: Bielefeld/Germany
Distribution: SuSE 7.3 German
Posts: 26

Original Poster
Rep: Reputation: 15
Thumbs up Thanks!

Thanks for your support!
Now I can make my small C-programs...
great!
Yours,
Bernhard
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Be Careful W/ That Rm Command, Kids! iatemyfingers Linux - Newbie 3 06-24-2005 03:12 PM
Why u need to be careful when using /dict/words... gumpo_mun General 8 07-12-2004 03:28 AM
programmers and developers careful of freeware ! davidmas123 Linux - Distributions 2 04-26-2004 05:48 PM
What should I be careful before installing fvwm on gnome ICO Linux - Newbie 2 11-24-2003 07:44 AM
when they say be careful doin something its a good idea to be careful lol eagle0669 Linux - Newbie 3 08-10-2001 08:43 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration