LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-28-2011, 12:22 PM   #1
knobby67
Member
 
Registered: Mar 2006
Posts: 627

Rep: Reputation: 43
stopping new line with asctime


Hi all,
I'm using asctime function to print the time to a file, however it always puts a new line with it, for example if I do

fprintf(pFile,"%s",asctime ( tm ));
fprintf(pFile,"hello world");

it writes

Fri Jan 28 18:11:38 2011
hello world

rather than


Fri Jan 28 18:11:38 2011 hello world

it's as if asctime adds \n to the end.

Is there a way round this? Thanks in advance
 
Old 01-28-2011, 12:31 PM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Uh, yes - asctime() *does* add "\n" to the end of the line. All you have to do is strip it off
 
1 members found this post helpful.
Old 01-28-2011, 01:07 PM   #3
z1p
Member
 
Registered: Jan 2011
Location: the right coast of the US
Distribution: Ubuntu 10.04
Posts: 80

Rep: Reputation: 23
Quote:
Originally Posted by paulsm4 View Post
Uh, yes - asctime() *does* add "\n" to the end of the line. All you have to do is strip it off
or use strftime instead and control your own destiny. ;^)
 
1 members found this post helpful.
Old 01-29-2011, 08:05 AM   #4
knobby67
Member
 
Registered: Mar 2006
Posts: 627

Original Poster
Rep: Reputation: 43
ThankS ALL
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ text file line by line/each line to string/array Dimitris Programming 15 03-11-2008 08:22 AM
php - Read file line by line and change a specific line. anrea Programming 2 01-28-2007 01:43 PM
Weired ctime() asctime() output azi Programming 1 07-01-2004 04:48 PM
stopping a command-line program from python kernelpanicguy Programming 0 09-08-2003 03:29 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration