Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

save formatted output from printf into variable
I have a printf statement that formats the output of my variables like below
:

printf("%-20s%-20s%-18s%-1s%-8s%-30s%-3s%-5s\n",aa,bb,cc,dd,ee,ff,gg,hh)

i would like to store this formatted output in the variable string. i.e.

print string

should give the same as

printf("%-20s%-20s%-18s%-1s%-8s%-30s%-3s%-5s\n",aa,bb,cc,dd,ee,ff,gg,hh)

any ideas?

awk newbie

Report this thread to moderator Post Follow-up to this message
Old Post
championsleeper
12-03-04 08:56 PM


Re: save formatted output from printf into variable

championsleeper wrote:
> I have a printf statement that formats the output of my variables like bel
ow:
>
> printf("%-20s%-20s%-18s%-1s%-8s%-30s%-3s%-5s\n",aa,bb,cc,dd,ee,ff,gg,hh)
>
> i would like to store this formatted output in the variable string. i.e.
>
>    print string
>
> should give the same as
>
> printf("%-20s%-20s%-18s%-1s%-8s%-30s%-3s%-5s\n",aa,bb,cc,dd,ee,ff,gg,hh)
>
> any ideas?


Use sprintf to format the string, then printf to print it.

Ed.

> awk newbie

Report this thread to moderator Post Follow-up to this message
Old Post
Ed Morton
12-03-04 08:56 PM


Re: save formatted output from printf into variable
Ed Morton <morton@lsupcaemnt.com> wrote in message news:<coiae7$cma@netnews.proxy.lucent.co
m>...
> championsleeper wrote: 
>
>
> Use sprintf to format the string, then printf to print it.
>
> 	Ed.
> 

hi ed,

thanks very much! show's how much of a newbie i am.

Report this thread to moderator Post Follow-up to this message
Old Post
championsleeper
12-07-04 08:59 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

AWK archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:17 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.