469,166 Members | 2,169 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,166 developers. It's quick & easy.

how to read .txt file in linux c code

hi.....
i m doinn 1 Dimensional DCT in C. I m New to UNIX so can anybody help me to do this program in unix using C code.i hav one text file as an input which contain 8 numbers as an input.so pls give me code or some link as early as possible.



thnxx in advance.....
Mar 17 '08 #1
5 8470
Laharl
849 Expert 512MB
Google "C file I/O". This is not really a *nix question, as the file opening/closing/reading code is not platform specific.
Mar 17 '08 #2
ashitpro
542 Expert 512MB
hi.....
i m doinn 1 Dimensional DCT in C. I m New to UNIX so can anybody help me to do this program in unix using C code.i hav one text file as an input which contain 8 numbers as an input.so pls give me code or some link as early as possible.



thnxx in advance.....
You are new to Unix, thats fine
But you know C I guess.
Just write your code in some c file say test.c.
You'll face the problem that which files to include.
For example. for opening your text file you'll use fopen
then just do 'man 2 fopen'. this will show you the list of files to include for this system call.
Compile your code by following command:
gcc -o test.c test
if you get any error then solve it or I am here to help you.
then run your binary as:
./test
You can write your code using vi editor or any thing else you like.
Mar 17 '08 #3
Google "C file I/O". This is not really a *nix question, as the file opening/closing/reading code is not platform specific.



thnxx. i thought there are some other methods of file operations in unix but these are all same like in windows.......thnxx for ur help...........


and are there any editor execpt vi editor to run a c code in unix just like,turbo c,dev-cpp for windows........



pls reply....



thnxx in advance.....
Mar 18 '08 #4
You are new to Unix, thats fine
But you know C I guess.
Just write your code in some c file say test.c.
You'll face the problem that which files to include.
For example. for opening your text file you'll use fopen
then just do 'man 2 fopen'. this will show you the list of files to include for this system call.
Compile your code by following command:
gcc -o test.c test
if you get any error then solve it or I am here to help you.
then run your binary as:
./test
You can write your code using vi editor or any thing else you like.





thnxx.......but man 2 fopen is not working on my pc.but now i m able to read txt file thnxx for tat.but give me list of some diffrent editors which are used for writing c code.....




thnxx in advance.....


waiting for ur reply.....
Mar 18 '08 #5
ashitpro
542 Expert 512MB
thnxx. i thought there are some other methods of file operations in unix but these are all same like in windows.......thnxx for ur help...........


and are there any editor execpt vi editor to run a c code in unix just like,turbo c,dev-cpp for windows........



pls reply....



thnxx in advance.....

vi is just an editor, like notepad in windows.
It is not IDE like turbo c where you can execute the code.
You can use other editors like 'nano','gedit'.

I suggest you 'fopen' because you were from windows platform.
There are standard POSIX compliant system calls on linux/unix like open,read,close,write etc.
including stdio.h alone can bring the support for fopen.
You can use open,read,close,write etc. sys calls by including following files.
sys/types.h,sys/stat.h,fcntl.h

Happy Coding.....
Mar 18 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

40 posts views Thread by Abby | last post: by
21 posts views Thread by sachin dooble | last post: by
2 posts views Thread by yezi | last post: by
2 posts views Thread by somequestion | last post: by
reply views Thread by chikhalepankaj | last post: by
1 post views Thread by chikhalepankaj | last post: by
3 posts views Thread by =?Utf-8?B?Sm9obiBXYWxrZXI=?= | last post: by
2 posts views Thread by xplode144 | last post: by
reply views Thread by leeamiin | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.