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
counter(n)						      Counters and Histograms							counter(n)

NAME
counter - Procedures for counters and histograms SYNOPSIS
package require Tcl 8 package require counter ?2.0? ::counter::init tag args ::counter::count tag ?delta? ?instance? ::counter::start tag instance ::counter::stop tag instance ::counter::get tag args ::counter::exists tag ::counter::names ::counter::histHtmlDisplay tag args DESCRIPTION
The counter package provides a counter facility and can compute statistics and histograms over the collected data. ::counter::init tag args This defines a counter with the name tag. The args determines the characteristics of the counter. The args are -group name Keep a grouped counter where the name of the histogram bucket is passed into ::counter::count. -hist bucketsize Accumulate the counter into histogram buckets of size bucketsize. For example, if the samples are millisecond time values and bucketsize is 10, then each histogram bucket represents time values of 0 to 10 msec, 10 to 20 msec, 20 to 30 msec, and so on. -hist2x bucketsize Accumulate the statistic into histogram buckets. The size of the first bucket is bucketsize, each other bucket holds values 2 times the size of the previous bucket. For example, if bucketsize is 10, then each histogram bucket represents time values of 0 to 10 msec, 10 to 20 msec, 20 to 40 msec, 40 to 80 msec, and so on. -hist10x bucketsize Accumulate the statistic into histogram buckets. The size of the first bucket is bucketsize, each other bucket holds values 10 times the size of the previous bucket. For example, if bucketsize is 10, then each histogram bucket represents time val- ues of 0 to 10 msec, 10 to 100 msec, 100 to 1000 msec, and so on. -lastn N Save the last N values of the counter to maintain a "running average" over the last N values. -timehist secsPerMinute Keep a time-based histogram. The counter is summed into a histogram bucket based on the current time. There are 60 per- minute buckets that have a size determined by secsPerMinute, which is normally 60, but for testing purposes can be less. Every "hour" (i.e., 60 "minutes") the contents of the per-minute buckets are summed into the next hourly bucket. Every 24 "hours" the contents of the per-hour buckets are summed into the next daily bucket. The counter package keeps all time-based histograms in sync, so the first secsPerMinute value seen by the package is used for all subsequent time-based histograms. ::counter::count tag ?delta? ?instance? Increment the counter identified by tag. The default increment is 1, although you can increment by any value, integer or real, by specifying delta. You must declare each counter with ::counter::init to define the characteristics of counter before you start to use it. If the counter type is -group, then the counter identified by instance is incremented. ::counter::start tag instance Record the starting time of an interval. The tag is the name of the counter defined as a -hist value-based histogram. The instance is used to distinguish this interval from any other intervals that might be overlapping this one. ::counter::stop tag instance Record the ending time of an interval. The delta time since the corresponding ::counter::start call for instance is recorded in the histogram identified by tag. ::counter::get tag args Return statistics about a counter identified by tag. The args determine what value to return: -total Return the total value of the counter. This is the default if args is not specified. -totalVar Return the name of the total variable. Useful for specifying with -textvariable in a Tk widget. -N Return the number of samples accumulated into the counter. -avg Return the average of samples accumulated into the counter. -avgn Return the average over the last N samples taken. The N value is set in the ::counter::init call. -hist bucket If bucket is specified, then the value in that bucket of the histogram is returned. Otherwise the complete histogram is returned in array get format sorted by bucket. -histVar Return the name of the histogram array variable. -histHour Return the complete hourly histogram in array get format sorted by bucket. -histHourVar Return the name of the hourly histogram array variable. -histDay Return the complete daily histogram in array get format sorted by bucket. -histDayVar Return the name of the daily histogram array variable. -resetDate Return the clock seconds value recorded when the counter was last reset. -all Return an array get of the array used to store the counter. This includes the total, the number of samples (N), and any type-specific information. This does not include the histogram array. ::counter::exists tag Returns 1 if the counter is defined. ::counter::names Returns a list of all counters defined. ::counter::histHtmlDisplay tag args Generate HTML to display a histogram for a counter. The args control the format of the display. They are: -title string Label to display above bar chart -unit unit Specify minutes, hours, or days for the time-base histograms. For value-based histograms, the unit is used in the title. -images url URL of /images directory. -gif filename Image for normal histogram bars. The filename is relative to the -images directory. -ongif filename Image for the active histogram bar. The filename is relative to the -images directory. -max N Maximum number of value-based buckets to display. -height N Pixel height of the highest bar. -width N Pixel width of each bar. -skip N Buckets to skip when labeling value-based histograms. -format string Format used to display labels of buckets. -text boolean If 1, a text version of the histogram is dumped, otherwise a graphical one is generated. counter 2.0 counter(n)