Sponsored Content
Top Forums Programming how to move file pointer to a particular line in c Post 302178591 by user_prady on Wednesday 26th of March 2008 01:29:34 AM
Old 03-26-2008
Quote:
Originally Posted by ramkrix
cool... I did not know the corect code to find the no of bytes per line and now i got abit visibility with your code.
ftell function obtains the current value of the file position indicator for the stream pointed to by stream.

May I have the content of your text file in which you use ftell? Atleast first ten lines.

Regards,
Ramkrix
Oh sure

0.137667 0.0595724
0.102683 0.109343
0.0508147 0.141131
-0.00941674 0.149706
-0.0681001 0.133655
-0.115576 0.09561
-0.144043 0.0418468
-0.148821 -0.0187982
-0.129114 -0.0763566
-0.0881689 -0.121354
-0.03272 -0.146388
0.0281091 -0.147345
0.0843097 -0.12406
0.126645 -0.0803778
0.148155 -0.0234622


I think the simple for loop will do that for me ..

Code:
for(i=0; i< my_pos; i++){
  fgets(fh);
}

Regards,
user_prady

Last edited by user_prady; 03-26-2008 at 03:01 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl how to move pointer to previous line in a txt file?

I have a text file that has blocks of text. Each block starts with ### and ends with End_###. I wrote a perl script to search a string from line 2 (ignore any line starts with ###) of each block if matched, need to print that whole block. According to the input file in below, it will print... (5 Replies)
Discussion started by: tqlam
5 Replies

2. Shell Programming and Scripting

how to move the line after a certain pattern in the file

Hi, I have a file called /bb/bin/rstrt. I need to move the line/entry "ccpm_load_shared_memory" after the entry "initcorp". The problem is that there are several entries for "initcorp" in this file and I need the entry to be moved only after the first instance of "initcorp" Is there a way... (5 Replies)
Discussion started by: aoussenko
5 Replies

3. Shell Programming and Scripting

Script to move the first line of a file to the end

I'm rather new to scripting, and despite my attempts at finding/writing a script to do what I need, I have not yet been successful. I have a file named "list.txt" of arbitrary length with contents in the following format: /home/user/Music/file1.mp3 /home/user/Music/file2.mp3... (21 Replies)
Discussion started by: Altay_H
21 Replies

4. Programming

pass a pointer-to-pointer, or return a pointer?

If one wants to get a start address of a array or a string or a block of memory via a function, there are at least two methods to achieve it: (1) one is to pass a pointer-to-pointer parameter, like: int my_malloc(int size, char **pmem) { *pmem=(char *)malloc(size); if(*pmem==NULL)... (11 Replies)
Discussion started by: aaronwong
11 Replies

5. Shell Programming and Scripting

Move a line to end of file

Can somebody help me with a script .... Read a file /etc/inittab find the string starting with rcml and move it entirely towards the end of file. rcml:2:once:/usr/sni/aix52/rc.ml > /dev/console 2>&1 I basically want to change the startup sequence. (2 Replies)
Discussion started by: imanuk2007
2 Replies

6. Shell Programming and Scripting

awk - if field is empty, move line to new file

I have a script with this statement: /usr/xpg4/bin/awk -F"" 'NR==FNR{s=$2;next}{printf "%s\"%s\"\n", $0, s}' LOOKUP.TXT finallistnew.txt >test.txt I want to include logic or an additional step that says if there is no data in field 3, move the whole line out of test.txt into an additional... (9 Replies)
Discussion started by: scriptr2be
9 Replies

7. Shell Programming and Scripting

move contents from one file to another based on line number or content

I want a script that will move everything beyond a certain line number or beyond a certain content word into another file. For example, if file A has this: first line second line third line forth line fifth line sixth line I want to run a script that will move everything beyond the third... (4 Replies)
Discussion started by: robp2175
4 Replies

8. Shell Programming and Scripting

Move a text to next line in a file

Hi , I need your help for the below issue. I have a file which has data as below An error came (/u01/app/12.csv) pkg1.func1: detail s 1111-->pkg1.func1: detail s 2222--> Now pkg1.func1: .... --> can come multiple times in the second line. I need to arrange the data in the below... (9 Replies)
Discussion started by: bhaski2012
9 Replies

9. Shell Programming and Scripting

Move a line to top of the file

Hi, I have a following file and it has only one occurrence of line that says "Output view:". It could be in middle somewhere ( i don't know the exact location ). I want to move it as the first line of the file. Input AAA BBBB CCCC Output view: XXXX YYYY ZZZZ Output should be: Output... (13 Replies)
Discussion started by: jakSun8
13 Replies

10. Solaris

Solaris 5.10 "Move Pointer" stuck

Hey there, I joined this forum just now cause I need help with an old SUN machine at work. I work on a helpdesk and we use a SOLARIS 5.10 OS. Every once in a while we will try to move one of our windows out of the way to make room on the desktop, and sometimes the mouse doesn't release what we... (7 Replies)
Discussion started by: TRex_2005
7 Replies
curs_move(3)						     Library Functions Manual						      curs_move(3)

NAME
curs_move, move, wmove - Move the Curses window cursor SYNOPSIS
#include <curses.h> int move( int y, int x ); int wmove( WINDOW *win, int y, int x ); LIBRARY
Curses Library (libcurses) STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: move, wmove: XCURSES4.2 Refer to the standards(5) reference page for more information about industry standards and associated tags. DESCRIPTION
These routines move the cursor associated with the Curses window to line y and column x. They do not move the physical cursor of the ter- minal until refresh is called. The specified position is relative to (0,0), which is the upper left-hand corner of the window. NOTES
The header file <curses.h> automatically includes the header file <stdio.h>. Note that move may be a macro. RETURN VALUES
These routines return the integer ERR upon failure and OK upon successful completion. SEE ALSO
Functions: curses(3), curs_refresh(3) Others: standards(5) curs_move(3)
All times are GMT -4. The time now is 07:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy