473,386 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 8716
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

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

Similar topics

40
by: Abby | last post by:
My .dat file will contain information like below. /////////// First 0x04 0x05 0x06 Second 0x07
21
by: sachin dooble | last post by:
is there any method where i can run my linux code that is all the a.out i made on linux to run on windows. plz tell me the way.
2
by: yezi | last post by:
Hi, ALl: The following code is to canculate 2 vector distance. Suppose the vectore is stored in some txt file like -1 0.34 0 0.045 1 0.98 1 0.01
2
by: somequestion | last post by:
During copying file , wanna read file Size like this string CheckFileSize(string fileName) { if( fileName == null ) return; FileInfo fi = new FileInfo(fileName); return fi.Length.ToString();...
0
by: chikhalepankaj | last post by:
Hi guys, I have a problem in reading a file content which r in tab separated value formate eg. MODULE AD0 AD1 AD2 AD3 AD4 AD5 AD6 AD7 4011 ...
1
by: chikhalepankaj | last post by:
Hi guys, I have a problem in reading a file content which r in tab separated value formate eg. MODULE AD0 AD1 AD2 AD3 AD4 AD5 AD6 AD7 4011 ...
3
by: =?Utf-8?B?Sm9obiBXYWxrZXI=?= | last post by:
Hi, Is there anything wrong with the code below in sending my browser page to Excel? Before my page opens in Excel there's a message "Problems came up in the following areas during load:" and it...
2
by: xplode144 | last post by:
I have a Web application. i need to read a file once during the startup and preserve the read data throughout the life of the application. i will to access the data often during the page_load of...
2
by: danimian | last post by:
Hello, first i am creating xml file if file does not exist. String myFile = "C:\myxmlfile.xml"; if (!File.Exists(myFile)) { using (FileStream conStream = new FileStream(myFile,...
0
by: leeamiin | last post by:
Hi, i need help with bellow file format, i work for telecom company and i'm the developer, what i need help with is to read file with bellow format, as you can see the file has { and , as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.