Re: how to implement tail -n

2005-01-23 Thread Eric Bambach
On Sunday 23 January 2005 11:49 pm, you wrote: > Hi, > > I would like to know how to implement "tail -n" in C. > > The "-n" option will be used to print the last n lines of a file - > rather than the default option of printing the last 10 lines of a file. > > I wish to do this in a single pass. I c

how to implement tail -n

2005-01-23 Thread Venkatesh Joshi
Hi, I would like to know how to implement "tail -n" in C. The "-n" option will be used to print the last n lines of a file - rather than the default option of printing the last 10 lines of a file. I wish to do this in a single pass. I can use lseek() to go to the end of the file. How to traverse

Re: pointer initialization of string constant

2005-01-23 Thread Krishna Mohan
Dear progga U are right. But my doubt is : when i run gdb and execute p ptr either just after or before printf, pbc has been displayed. I'm getting segmentation fault only at the end, it seems, because when i run ./a.out "pbc is not displayed" but prompted segmentation fault error. why is it so?

Re: pointer initialization of string constant

2005-01-23 Thread Progga
On Sun, Jan 23, 2005 at 11:56:11AM +0530, Krishna Mohan wrote: > > main() > { > char *ptr = "abc"; > ptr[0] = 'p'; Since ptr points to read-only mem, changing ptr[0] does not seem to be a very wise idea. - To unsubscribe from this list: send the line "unsubscribe linux-c-progra