UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C
  • » Print in columns

#1 2007-12-17 03:58 PM

eusta
Member
Registered: 2006-12-13
Posts: 33

Re: Print in columns

Hello,

I want to print strings in ordering as below

string1           string11
string11111     string22222222
string33          string33333
string4444444  string55

Is there any special function?

Thanks in advance

Offline

#2 2007-12-17 04:09 PM

i3839
Oddministrator
From: Amsterdam
Registered: 2003-06-07
Posts: 2,239

Re: Print in columns

Just use printf(). Use the width option to use fixed sizes to align the columns, and newlines to start new rows. Read the manpage carefully for the precise format.

Offline

#3 2007-12-17 04:50 PM

eusta
Member
Registered: 2006-12-13
Posts: 33

Re: Print in columns

This worked perfect printf("%-20s %-20s \n"....);

Offline

  • Index
  • » C
  • » Print in columns

Board footer

Powered by FluxBB