switching to ansi c

13 replies [Last post]
anish
Offline
Last seen: 10 years 17 weeks ago
Joined: 2009-04-08
bOt Points: 94

i have been using tc(version 3) till now and now plan to switch to ansi c.what changes should  i make in my programs so that i can compile on gcc(that what i will be using from now)

codeguru
Offline
Last seen: 10 years 21 weeks ago
Joined: 2009-04-08
bOt Points: 114
thank God u switched. TC (the

thank God u switched.

TC (the one u were using) was probably as old as u.

 

making your codes ansi complaint aint a big deal...atleast right now(since you had been using tc (v.3) till now i assume you are still a beginner) .

 

to get started with

main cannot retun void, it must return a value

remove clrscr() from your codes and possibly all functions that require conio.h(only some compilers support it)

 

some special notes for C++

the traditonal header

i.e #include<iostream.h>

 have been depreceated

use this syntax

#include<iostream>  (i.e without the .h extension)

also

for

stdio.h use   cstdio

stdlib.h use cstdlib

math.h  use cmath

 

 i think these changes should suffice for now.

if you have any problems..............this forums is always open for u

 

 

bOtskOOl
Offline
Last seen: 9 years 31 weeks ago
Joined: 2009-02-21
bOt Points: 3500
Reply: switching to ansi c

codeguru has indeed written a good post and pointed out almost all the required stuff.

 

A few  more points to remember-

For C++ you also need to add the following line in the beginning of your code

 

using namespace std;

 

or else you will have to use

std::cout , std::cin etc in place of any object/function you use from iostream.

 

namspaces form a very new feature of c++ whose details are being excluded. Anyways we will be very soon putting up a tutorial on namesapces in our programming tutorials section.

 

 

mike
Offline
Last seen: 10 years 25 weeks ago
Joined: 2009-03-31
bOt Points: 66
GCC!!

Gcc is much much better than TC....thats true....

can somebody tell me if a executable file is created or not in GCC??

using terminal is the only way out?

dhanunjaya
Offline
Last seen: 9 years 33 weeks ago
Joined: 2009-04-26
bOt Points: 153
where u r man

i am from cdac we prefer visual c++,as well as gcc compiler these are the best compilers.visual c++ is from microsoft,if u install any linux operating system by default u can get gcc package

shotgun
Offline
Last seen: 10 years 21 weeks ago
Joined: 2009-03-20
bOt Points: 122
@mike i don think that gcc

@mike

i don think that gcc produce any executable file

 

@dhanunjay

dude can i ask wat is cdac??

dhanunjaya
Offline
Last seen: 9 years 33 weeks ago
Joined: 2009-04-26
bOt Points: 153
did u worked on gcc

center for development of advanced computing

 

 

shotgun
Offline
Last seen: 10 years 21 weeks ago
Joined: 2009-03-20
bOt Points: 122
little bit !!

little bit !!

 

have you??

 

have u tried online compiler on this site?

its really very good!

shotgun
Offline
Last seen: 10 years 21 weeks ago
Joined: 2009-03-20
bOt Points: 122
CDAC!!

do you work or study at cdac?

dhanunjaya
Offline
Last seen: 9 years 33 weeks ago
Joined: 2009-04-26
bOt Points: 153
CDAC

i am doing diploma in embedded systems

shotgun
Offline
Last seen: 10 years 21 weeks ago
Joined: 2009-03-20
bOt Points: 122
u r working in embedded

u r working in embedded system then codebolcks will be very useful to you!!

 

codeblocks can be used to programs microcontrollers too!

 

can visual c++ do it??

dhanunjaya
Offline
Last seen: 9 years 33 weeks ago
Joined: 2009-04-26
bOt Points: 153
compiler

its not for microcontrollers

 

its for high level languages

shotgun
Offline
Last seen: 10 years 21 weeks ago
Joined: 2009-03-20
bOt Points: 122
okk!!

okk!!

 

so cheers to codeblocks

codeguru
Offline
Last seen: 10 years 21 weeks ago
Joined: 2009-04-08
bOt Points: 114
generating exe with gcc

yes thats possible..............you can actually generate an windows exectuable using gcc

it is called cross compiling.

 

its a bit difficuly in getting it to work especially for new users

nyways, for those really interested  you need to install mingw32 binutils  alongwith gcc on the system.

For ubuntu users , they can easily do it through synaptic.