Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

newbie trying to setup VERY SIMPLE C environment

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
hertelbrian
Posts: 13
Joined: 2006-10-05 22:49

newbie trying to setup VERY SIMPLE C environment

#1 Post by hertelbrian »

ok, let me start this off by saying i'm very new to linux, i'm using debian 2.4.27/-3-386.

im trying to setup an environment that i can compile some very basic C code in. all i want to do right now is read in a file... using the fstream.h
i have downloaded and installed the libc6.dev package...

when i am in the directory my C file lies in and run gcc to compile it.. i get a bunch of errors, first off the bad is that it cant find the fstream.h file.. so i found the path for it.. and put it in my include statement and then the compiler yelled at me for one of the first lines in fstream.h

i'm used to a windows environment and i really am shooting in the dark, all i want to do is compile a very basic C program nothign fancy.. ANY help would be appreciated...

remember
NEWBIE!
thanks in advance

ajdlinux
Posts: 2452
Joined: 2006-04-23 09:37
Location: Port Macquarie, NSW, Australia

#2 Post by ajdlinux »

Look at http://www.daniweb.com/techtalkforums/thread11430.html - you will see that you need to include 'fstream', not 'fstream.h'. Also I believe fstream is C++, not C - correct me if I'm wrong.
Jabber: xmpp:ajdlinux@jabber.org.au
Spammers, email this: ajdspambucket@exemail.com.au

hertelbrian
Posts: 13
Joined: 2006-10-05 22:49

#3 Post by hertelbrian »

very well could be C++ but when i tried including as fstream and fstream.h ... when i do fstream it yells at me saying no file exists.. when i do fstream.h compiler yells at me because one of the first lines in fstream.h... it doesnt recognize...

ajdlinux
Posts: 2452
Joined: 2006-04-23 09:37
Location: Port Macquarie, NSW, Australia

#4 Post by ajdlinux »

It probably doesn't recognise it because a C compiler can't compile C++ code.
Jabber: xmpp:ajdlinux@jabber.org.au
Spammers, email this: ajdspambucket@exemail.com.au

beissemj
Posts: 38
Joined: 2006-07-19 13:53

#5 Post by beissemj »

filestream.h is used in c++, not c. So you need to use g++ to compile it.

Code: Select all

#include <fstream>

int main(void){
  ifstream in("somefile");

    while(!in.eof()) {
          //do something 
	}

	in.close();   
}

Code: Select all

$ g++ yourfile.cpp -o executible_name

hertelbrian
Posts: 13
Joined: 2006-10-05 22:49

#6 Post by hertelbrian »

beissemj

thanks man... aparently using the correct compiler makes a difference... WHO WOULDA THUNK IT!

Post Reply