-1

With

fprintf(f,"%d %d %d\n",m,l,k);

I got

8 0 98
8 1 98
8 2 98
9 0 98
9 1 98
9 2 98
10 0 98
10 1 98
10 2 98
11 0 98
11 1 98
11 2 98
12 0 98
12 1 98
12 2 98
13 0 98
13 1 98

What I really want is that each line has same format,like this

9  2 98
10 0 98
ameyCU
  • 16,489
  • 2
  • 26
  • 41
Richard Rublev
  • 7,718
  • 16
  • 77
  • 121
  • This should help http://stackoverflow.com/questions/3187149/c-equivalent-of-the-setw-function – Jeyaram Apr 01 '16 at 13:52
  • @Jeyaram Yes,I got it. – Richard Rublev Apr 01 '16 at 13:53
  • Sorry this is a well documented aspect, I was have tempted to copy and paste a "Let me google that for you" link. [External Link](http://www.codingunit.com/printf-format-specifiers-format-conversions-and-formatted-output) or [External Link 2](http://en.cppreference.com/w/cpp/io/c/fprintf) or [External Link 3](http://www.cplusplus.com/reference/cstdio/printf/) – SGM1 Apr 01 '16 at 14:01

1 Answers1

2

This code

fprintf(f,"%2d %d %2d\n",m,l,k);

yields:

9  2 98
10 0 98
meskobalazs
  • 15,741
  • 2
  • 40
  • 63