LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-09-2010, 02:35 PM   #1
bobnos
LQ Newbie
 
Registered: Jun 2010
Posts: 3

Rep: Reputation: 0
How to save my code?


Hello and Good Evening to everyone!

Situation:

I've written the following code in Vim (trying to write in C)

PHP Code:
#include<stdio.h
/* To prwto mou programma */
int main (void)
{
printf("Hello, world!\n");

return 
0;

And that's were I got stacked :P

I don't know how to save my file (example: hello.c)

(that's a classic example as you know :P)

I just don't get it..

Any help?

Thank you in advance

P.S: Here is a screen shot of my situation..

Sreen shot

Last edited by bobnos; 06-09-2010 at 02:40 PM. Reason: Screen shot added ;)
 
Old 06-09-2010, 02:39 PM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware & Android
Posts: 7,565

Rep: Reputation: 696Reputation: 696Reputation: 696Reputation: 696Reputation: 696Reputation: 696
Vim is crazy. Once you get there, type ESC : wq and then press return

the ':' puts it in command mode
 
Old 06-09-2010, 02:40 PM   #3
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
Heh ... welcome to LQ!


You need to find a vi tutorial or cheat sheet ;}


Code:
<ESC>:wq
will save your file and quit vim


Cheers,
Tink
 
Old 06-09-2010, 02:47 PM   #4
bobnos
LQ Newbie
 
Registered: Jun 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks!

Thank you both of you!

I finally got it :P

@Tinkster

Do you have any link to get a -really good- vim tutorial?

edit: I type the following command in terminal:

Code:
bobnos@ubuntu:~$ gcc hello.c -o hello.out
and I get this error:

Code:
hello.c:1:17: error: missing terminating > character
what is that and how can I fix it?

Thnx

Last edited by bobnos; 06-09-2010 at 03:00 PM. Reason: question added
 
Old 06-09-2010, 03:12 PM   #5
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
For your include directive, you need #include <stdio.h>. The ">" at the end is missing. Really, though, the error message should have been sufficient - it even tells you the line number where the problem is!
 
Old 06-09-2010, 04:25 PM   #6
onebuck
Moderator
 
Registered: Jan 2005
Location: Midwest USA, Central Illinois
Distribution: SlackwareŽ
Posts: 12,541
Blog Entries: 23

Rep: Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943Reputation: 1943
Hi,

Welcome to LQ!

Learning vi - "cheat sheet" technique is a good tutorial that will show you how to use vi, a powerful visual editor.


The above link and others can be found at 'Slackware-Links'. More than just SlackwareŽ links!
 
Old 06-09-2010, 08:03 PM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,246

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
You will soon learn that vim also has a heap a ways of doing things, but I just thought I would add that the following are equivalent:

Code:
<ESC>:wq

<ESC>:x
 
Old 06-10-2010, 01:30 AM   #8
shai333
LQ Newbie
 
Registered: Jun 2010
Distribution: Ubuntu
Posts: 15

Rep: Reputation: 0
In addition to everything that has been said,
you might wanna try using an easier tool, such as Geany.
 
Old 06-10-2010, 03:54 AM   #9
bobnos
LQ Newbie
 
Registered: Jun 2010
Posts: 3

Original Poster
Rep: Reputation: 0
Thank you for your answers.

But I've still have a problem

I add > as someone told me before.

Then I wrote this code:

PHP Code:
gcc hello.-o hello.out 
hello.out created but..

When I open it, nothing happen. Does anyone know why? :S
 
Old 06-10-2010, 04:00 AM   #10
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,246

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Quote:
When I open it, nothing happen. Does anyone know why?
Please explain what you mean by "open"?

You should be executing hello.out:
Code:
./hello.out
 
Old 06-10-2010, 05:08 AM   #11
alan99
Member
 
Registered: Mar 2010
Distribution: Debian
Posts: 180

Rep: Reputation: 31
Quote:
Originally Posted by bobnos View Post
Thank you for your answers.

But I've still have a problem

I add > as someone told me before.

Then I wrote this code:

PHP Code:
gcc hello.-o hello.out 
hello.out created but..

When I open it, nothing happen. Does anyone know why? :S
gcc will just compile it to object code. I think he forgot the next step. It must be linked. The linker will insert some 'headers' in the object file telling the operating system where to find the entry point for the code and any parameters it may be passing.
 
Old 06-10-2010, 05:13 AM   #12
alan99
Member
 
Registered: Mar 2010
Distribution: Debian
Posts: 180

Rep: Reputation: 31
Most systems will probably be using ELF as the executable format. a.out may not work on his system.
 
Old 06-10-2010, 05:54 AM   #13
timmeke
Senior Member
 
Registered: Nov 2005
Location: Belgium
Distribution: Red Hat, Fedora
Posts: 1,515

Rep: Reputation: 61
As for vi, typing
Code:
ZZ
will also save + quit, without the need for command mode.
 
Old 06-10-2010, 07:00 AM   #14
sica07
Member
 
Registered: May 2008
Distribution: Arch
Posts: 47
Blog Entries: 3

Rep: Reputation: 16
For a good vi tutorial read A byte of Vim
 
Old 06-10-2010, 07:54 AM   #15
TheIndependentAquarius
Senior Member
 
Registered: Dec 2008
Posts: 4,672
Blog Entries: 29

Rep: Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917Reputation: 917
Quote:
Originally Posted by bobnos View Post
Thank you for your answers.

But I've still have a problem

I add > as someone told me before.

Then I wrote this code:

PHP Code:
gcc hello.-o hello.out 
hello.out created but..

When I open it, nothing happen. Does anyone know why? :S
See if the following thread helps you !
http://www.linuxquestions.org/linux/...grams_on_Linux
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Java code to implement "wget" to save a web page in linux Kakarot_Rathish Programming 5 03-08-2010 03:02 AM
Any idea where to find PHP code for a sharing Notepad webpage with auto-save? frenchn00b Programming 1 11-30-2009 09:09 PM
How to save text file with ASCII code?? Nejad General 7 01-04-2009 03:17 AM
HTML code to use to save a downloaded file with an other name that the URL jlinkels Programming 4 06-21-2007 08:40 PM
suggestions on how to code a program that would edit and save a text file tinieprotonjam Programming 5 01-28-2007 07:28 AM


All times are GMT -5. The time now is 06:24 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration