LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 09-06-2010, 08:44 AM   #1
sainiankit
LQ Newbie
 
Registered: Sep 2010
Posts: 8

Rep: Reputation: 0
Any difference in C programming in Gedit & Turbo c


In our college all the systems (running on windows xp) have TURBO C/C++ installed on them which we use for C programming.
I recently installed ubuntu 10.04 on me laptop (DELL Inspiron 14R (N4010) with some modifications)
i read somewhere on the internet that Gedit can be used for writing a programme in ubuntu which can be compiled using gcc.
Well if i use Gedit rather than Turbo c will i experience any differnce?, i mean is there any problem in doing so??
Or i should prefer running turbo c using DOS BOX?
 
Old 09-06-2010, 09:41 AM   #2
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,032
Blog Entries: 52

Rep: Reputation: Disabled
Gedit is a text editor GCC is the most common compiler on Linux. I don't know enough about programming to tell you the differences between GCC and Turbo C.
 
Old 09-06-2010, 11:24 AM   #3
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
You can use any text editor that suits your taste. As long as it produces plain-text files (ie. it isn't a word processor), you're good to go. The list of available possibilities on Linux is long. You can probably use files created on DOS/Windows with the Turbo C editor, although there may be issues with the DOS CR-LF end-of-lines. There are tools to convert the DOS end-of-line to Unix style line ends (and I can never remember the name of one, so when needed, I tend to just write my own).
--- rod.
 
Old 09-06-2010, 11:47 AM   #4
rikijpn
Member
 
Registered: Jun 2007
Location: Japan
Distribution: Debian lenny, DSL, Solaris 10
Posts: 157

Rep: Reputation: 33
Quote:
Originally Posted by theNbomr View Post
You can use any text editor that suits your taste. As long as it produces plain-text files (ie. it isn't a word processor), you're good to go. The list of available possibilities on Linux is long. You can probably use files created on DOS/Windows with the Turbo C editor, although there may be issues with the DOS CR-LF end-of-lines. There are tools to convert the DOS end-of-line to Unix style line ends (and I can never remember the name of one, so when needed, I tend to just write my own).
--- rod.
I assume turbo c is an editor. Maybe it compiles for you as well?
You can write the source code in any editor (even windows' notepad), and then just compile it as you want.
However, if you compile something in linux, you won't be able to use the executable file in windows. You would have to get the source, copy it to the windows machine, and recompile it there.
As above, this will get you with one problem when reading the file, which is because "newlines" definition in windows and linux are different. You can use a program like unix2dos (to change the file's "newlines" from the linux' to windows'), or dos2unix (for the opposite).

Anyway, the most common compilers in GNU/Linux are "gcc" for C code, and "g++" for C++ code.
There are some editors that make it easy for you to compile a file, by putting a "compile" button or something around, and calling the compiler by themselves. emacs would be nice I think. There have to be other IDEs around too. Look in your package manager.
 
Old 09-06-2010, 12:41 PM   #5
rhklinux
Member
 
Registered: Jan 2010
Location: india/pune
Distribution: Arch Fedora20
Posts: 126

Rep: Reputation: 18
if you want to switch from tc to gcc then
1)you have to replace conio.h to stdlib.h (stdlib.h contains most of the functions in conio)though you can't use something like
Quote:
clrscr()
in linux yet there is also a replacement to it
Quote:
system("clear");
2) to compile ....
gcc -o objname filename.c
./objname
here replace filename.c by you c filename and objname by the name you want to give to obj file(you can give any name here)

3)you can also use vim instead of gedit !!

4)return data type of main in tc is void but in linux it is int.with successful exit it returns 0;
 
Old 09-06-2010, 02:17 PM   #6
jay73
Guru
 
Registered: Nov 2006
Location: Belgium
Distribution: Ubuntu 11.04, Debian testing
Posts: 5,019

Rep: Reputation: 130Reputation: 130
I think the main difference is that they deal with errors in different ways. For example, if you use wrong types, one will produce a zero and the other will produce some other, random value.
Here is a short intro to gcc:
http://www.network-theory.co.uk/docs...tro/index.html
GNU C:
http://www.gnu.org/software/libc/manual/
 
Old 09-06-2010, 03:05 PM   #7
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,114

Rep: Reputation: 312Reputation: 312Reputation: 312Reputation: 312
As long as you're writing ANSI/ISO standard C, there should not be any differences between writing programs on Linux using any editor and compiling with gcc versus writing them on Windows. However, if you have to use Windows specific extensions to the core C language then those obviously won't work natively under Linux (likewise *nix-specific C extensions tend not to work under Windows).
 
Old 09-07-2010, 11:31 AM   #8
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
In case the concept is (still) unclear, there is a difference between creating C source code, and building a working program from said source code. Using a different editor to successfully create C source code says nothing about the success or failure of the code to build under different compilers and architectures. As others have pointed out, Turbo C is targeted to a DOS/Win architecture, and many of the 'features' that are commonly used in that environment are not portable to the Linux environment. Using only ANSI standard C should allow the code to operate equally well in any conforming architecture (assuming Turbo C does conform to ANSI standard C, which I believe it does).
When using tools such as Turbo C and other IDEs, the beginning programmer often loses sight of what elements make up the build process. Using discrete tools such as editor, compiler, linker, and other toolchain components, one tends to develop a clearer understanding of the phases and elements of the software development process. Welcome to the Linux programming world.
--- rod.
 
  


Reply

Tags
gedit


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
Regular Expression Search & Replace in Writer or gedit linuxqueric Linux - Newbie 5 03-03-2013 07:00 PM
Difference between Userland programming and Kernel Programming.. meetsagittarian Programming 1 02-20-2006 12:26 AM
what is the difference between ch and 'ch' - C programming indian Programming 3 09-30-2005 11:32 AM
Difference between Top Down programming & Bottom up programming minil Programming 1 06-17-2005 02:42 AM


All times are GMT -5. The time now is 07:30 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration