c file to extract real value from a txt file


 
Thread Tools Search this Thread
Top Forums Programming c file to extract real value from a txt file
# 8  
Old 02-04-2008
Quote:
Originally Posted by user_prady
Dear Friends,

I am really in a great problem.
My problem is as follows

If I will send a counter to a function in c like read_line(counter);

Then it will read that line only which counter is pointing ,
Suppose I ve txt file like below

abc.txt
12.1
13.2
14.4

Then If I'll call the function as read_line(2);

It should read the 2nd line only and then put that value to a double pointer..

I mean one function call should read only the specified row,, and store it to a double pointer..

I need help badly..
One way you could do this is by moving the sscanf part of the code into the read_line() function. This way you just need to increment the variable by 1 after every call to fgets. After calling fgets you can invoke read_line() and pass the counter as an argument to it and inside read_line() the double floating number will be stored at the address specified by the double pointer using sscanf.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

To extract values after the maximum value in a txt file

Hello, I'm new to scripting and I need to write a bash script. Here is example of file on which I'm working: 0.3092381 0.3262799 0.3425480 0.3578379 0.3719490 0.3846908 0.3958855 0.4053738 0.4130160 0.4186991 0.4223357 ... (1 Reply)
Discussion started by: jeo_fb
1 Replies

2. Shell Programming and Scripting

Extract information from txt file

Hello! I need help :) I have a file like this: AA BC FG RF TT GH DD FF HH (a few number of rows and three columns) and I want to put the letters of each column in a variable step by step in order to give them as input in another script. So I would like to obtain: for the 1° loop:... (11 Replies)
Discussion started by: edekP
11 Replies

3. Shell Programming and Scripting

Script extract text from txt file with grep

All, I require a script that grabs some text from the gitHub API and will grep (or other function) for a string a characters that starts with (") quotes followed by two letters, may contain a pipe |, and ending with ) . What i have so far is below but it's not returning anything. ... (4 Replies)
Discussion started by: ChocoTaco
4 Replies

4. Windows & DOS: Issues & Discussions

2 Questions: replace text in txt file, add text to end of txt file

so... Lets assume I have a text file. The text file contains multiple "#" symbols. I want to replace all thos "#"s with a STRING using DOS/Batch I want to add a certain TEXT to the end of each line. How can I do this WITHOUT aid of sed, grep or anything linux related ? (1 Reply)
Discussion started by: pasc
1 Replies

5. Shell Programming and Scripting

Need to append the date | abcddate.txt to the first line of my txt file

I want to add/append the info in the following format to my.txt file. 20130702|abcd20130702.txt FN|SN|DOB I tried the below script but it throws me some exceptions. <#!/bin/sh dt = date '+%y%m%d'members; echo $dt+|+members+$dt; /usr/bin/awk -f BEGIN { FS="|"; OFS="|"; } { print... (6 Replies)
Discussion started by: harik1982
6 Replies

6. Shell Programming and Scripting

Command to extract all columns except the last few from a txt file

hello, i have publicly available txt file with little less than 300000 rows. i want to extract from column 1 to column 218 and save it in another text file. i use the cut command but the file is saved with multiple rows from the source file onto a single row in the destination. basically it is... (6 Replies)
Discussion started by: madrazzii
6 Replies

7. Shell Programming and Scripting

awk append fileA.txt to growing file B.txt

This is appending a column. My question is fairly simple. I have a program generating data in a form like so: 1 20 2 22 3 23 4 12 5 43 For ever iteration I'm generating this data. I have the basic idea with cut -f 2 fileA.txt | paste -d >> FileB.txt ???? I want FileB.txt to grow, and... (4 Replies)
Discussion started by: theawknewbie
4 Replies

8. UNIX for Dummies Questions & Answers

Extract numbers from .txt file

I need to extract all the p-value numbers and the rho numbers from a .txt file and write them as coma separated values in a new file. Ideally I would get two files in the end, one for p- values and one for rho. Any suggestions? I appreciate your help!!! The .txt file looks essentially like this... (5 Replies)
Discussion started by: eggali
5 Replies

9. Shell Programming and Scripting

Extract from txt file

I have data as follow in the txt file. I want to skip line starting with '#' sign. #command program abc defmt exp refmt ... ... I want to store abc exp .... in a array. I want to store defmt refmt in a array I need command to read each line in the file. I need... (6 Replies)
Discussion started by: ekb
6 Replies

10. UNIX for Dummies Questions & Answers

Binary txt file received when i use uuencode to send txt file as attachment

Hi, I have already read a lot of posts on sending attachments in unix...but none of them were of help for my problem...so here goes.. i wanna attach a text file and send to a mail id..used the following code : uuencode "$File1" "$File1" ;|mail -s "$Mail_sub" abc@abc.com it works... (2 Replies)
Discussion started by: ash22
2 Replies
Login or Register to Ask a Question
IO::BufferedSelect(3pm) 				User Contributed Perl Documentation				   IO::BufferedSelect(3pm)

NAME
IO::BufferedSelect - Line-buffered select interface SYNOPSIS
use IO::BufferedSelect; my $bs = new BufferedSelect($fh1, $fh2); while(1) { my @ready = $bs->read_line(); foreach(@ready) { my ($fh, $line) = @$_; my $fh_name = ($fh == $fh1 ? "fh1" : "fh2"); print "$fh_name: $line"; } } DESCRIPTION
The "select" system call (and the "IO::Select" interface) allows us to process multiple streams simultaneously, blocking until one or more of them is ready for reading or writing. Unfortunately, this requires us to use "sysread" and "syswrite" rather than Perl's buffered I/O functions. In the case of reading, there are two issues with combining "select" with "readline": (1) "select" might block but the data we want is already in Perl's input buffer, ready to be slurped in by "readline"; and(2) "select" might indicate that data is available, but "readline" will block because there isn't a full $/-terminated line available. The purpose of this module is to implement a buffered version of the "select" interface that operates on lines, rather than characters. Given a set of filehandles, it will block until a full line is available on one or more of them. Note that this module is currently limited, in that(1) it only does "select" for readability, not writability or exceptions; and(2) it does not support arbitrary line separators ($/): lines must be delimited by newlines. CONSTRUCTOR
new ( HANDLES ) Create a "BufferedSelect" object for a set of filehandles. Note that because this class buffers input from these filehandles internally, you should only use the "BufferedSelect" object for reading from them (you shouldn't read from them directly or pass them to other BufferedSelect instances). METHODS
read_line read_line ($timeout) read_line ($timeout, @handles) Block until a line is available on one of the filehandles. If $timeout is "undef", it blocks indefinitely; otherwise, it returns after at most $timeout seconds. If @handles is specified, then only these filehandles will be considered; otherwise, it will use all filehandles passed to the constructor. Returns a list of pairs "[$fh, $line]", where $fh is a filehandle and $line is the line that was read (including the newline, ala "readline"). If the filehandle reached EOF, then $line will be undef. Note that "reached EOF" is to be interpreted in the buffered sense: if a filehandle is at EOF but there are newline-terminated lines in "BufferedSelect"'s buffer, "read_line" will continue to return lines until the buffer is empty. SEE ALSO
IO::Select AUTHOR
Antal Novak, <afn@cpan.org> COPYRIGHT AND LICENSE
Copyright (C) 2007 by Antal Novak This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available. perl v5.10.1 2007-03-13 IO::BufferedSelect(3pm)