473,408 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Is it legal?

Hello,

Is it legal to write

printf(" %+*.*f",5,0,A[r][c]);

Instead of

printf(" %+5.0f",A[r][c]);

Thank

Aug 23 '06 #1
10 1423
xhungab wrote:
Hello,

Is it legal to write

printf(" %+*.*f",5,0,A[r][c]);

Instead of

printf(" %+5.0f",A[r][c]);

Thank
Hi!

Yes it is for example with GNU C library as said in
http://www.gnu.org/software/libc/man...atted%20Output.

But they also say "Other C library versions may not recognize this syntax."

Konstantin
Aug 23 '06 #2
xhungab wrote:
Hello,

Is it legal to write

printf(" %+*.*f",5,0,A[r][c]);

Instead of

printf(" %+5.0f",A[r][c]);

Thank
You mean with the + in it ? Looks yucky anyways. Why would you want to
do this like that?
Try invoking your compiler in C90 / C99 mode, depending on which
standard you want to adhere to, and enable strict/pedantic mode.

Sh
Aug 23 '06 #3
Schraalhans Keukenmeester wrote:
xhungab wrote:
>Hello,

Is it legal to write

printf(" %+*.*f",5,0,A[r][c]);

Instead of

printf(" %+5.0f",A[r][c]);

Thank
You mean with the + in it ? Looks yucky anyways. Why would you want to
do this like that?
Try invoking your compiler in C90 / C99 mode, depending on which
standard you want to adhere to, and enable strict/pedantic mode.

Sh
What is wrong with the + ?

kmi
Aug 23 '06 #4
Konstantin Miller wrote:
Schraalhans Keukenmeester wrote:
>xhungab wrote:
>>Hello,

Is it legal to write

printf(" %+*.*f",5,0,A[r][c]);

Instead of

printf(" %+5.0f",A[r][c]);

Thank
You mean with the + in it ? Looks yucky anyways. Why would you want to
do this like that?
Try invoking your compiler in C90 / C99 mode, depending on which
standard you want to adhere to, and enable strict/pedantic mode.

Sh

What is wrong with the + ?

kmi
Nothing in particular, I just think it's bad coding style.
Either the actual width already is a positive and the + does not change
that, or it's a negative, in which case the + doesn't make it otherwise,
while a glimpse at the code may give the reader the suggestion it's a
positive value he/she is dealing with. As such, the + seams completely
useless here. Unless *I* have missed some other meaning of the + in this
example. In which case I'd stand corrected once you educate me further ;)

Kindest
Sh.
Aug 23 '06 #5
It is for this function.

In this way I can choose the format for any matrices.

void p_mR(
double **A,
int e,
int d
)
{
int r;
int c;

for(r=FIRST; r<A[R_SIZE][OF]; r++)
{
printf("\n");
for (c=FIRST; c<A[C_SIZE][OF]; c++)

printf(" %+*.*f",e,d,A[r][c]);
}
printf("\n\n");
}

Aug 23 '06 #6
Schraalhans Keukenmeester <fi********************@xsfourall.ennelwrote:
>printf(" %+*.*f",5,0,A[r][c]);
What is wrong with the + ?
Nothing in particular, I just think it's bad coding style.
Not so. It merely indicates the programmer's desire that the numeric
output always be preceded by a '+' or a '-' sign. It means the same
thing in

printf( "%+f", A[r][c] );

and may well produce exactly the behavior the programmer requires.
useless here. Unless *I* have missed some other meaning of the + in this
example. In which case I'd stand corrected once you educate me further ;)
You did :-)

--
C. Benson Manica | I *should* know what I'm talking about - if I
cbmanica(at)gmail.com | don't, I need to know. Flames welcome.
Aug 23 '06 #7
Thank for your help.

Aug 23 '06 #8

"xhungab" <xh*****@yahoo.frwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
It is for this function.
What is for this function? What do you mean by "it"?
>
In this way I can choose the format for any matrices.

void p_mR(
double **A,
int e,
int d
)
{
int r;
int c;

for(r=FIRST; r<A[R_SIZE][OF]; r++)
{
printf("\n");
for (c=FIRST; c<A[C_SIZE][OF]; c++)

printf(" %+*.*f",e,d,A[r][c]);
}
printf("\n\n");
}

Aug 23 '06 #9
The command :

printf(" %+*.*f",e,d,A[r][c]);

was for this function.

void p_mR(
double **A,
int e,
int d
)
{
int r;
int c;
for(r=FIRST; r<A[R_SIZE][OF]; r++)
{
printf("\n");
for (c=FIRST; c<A[C_SIZE][OF]; c++)
printf(" %+*.*f",e,d,A[r][c]);
}
printf("\n\n");
}
I use this function to print real matrices.
..
..

Aug 23 '06 #10

xhungab wrote:
Hello,

Is it legal to write

printf(" %+*.*f",5,0,A[r][c]);

Instead of

printf(" %+5.0f",A[r][c]);
Yes, it's standard printf() format syntax.

Aug 24 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: pakkocool | last post by:
¿Como ganar dinero en internet? Lee atentamente el siguiente texto, es super interesante y te hara ganar muchos dolares si sigues las instrucciones y le pones empeño: Hace unos días que...
3
by: Chris Johnson | last post by:
Greetings all: I come across an interesting question (to me anyway) and I do not know the answer. Code/Questions follow: #include <iostream> #if 0 // uncommenting *should* make call...
7
by: Nice | last post by:
Hi. I read somewhere that in XML the tag <xml> is not legal. But in W3C specs I can't find this statement. Does anyone know about it ?
0
by: mykidisgollum | last post by:
Greetings, I have code which prints a document who's attributes are saved as flags in a database. One of the those attributes is letter or legal. When I am printing, I use the following...
7
by: __PPS__ | last post by:
Actually what I mean is that - if I have some memory buffer, lets say char a; and then I do like this: DWORD num = 0x1234; *(DWORD*)a = num; (1) *(DWORD*)(a+1) = num; (2) either...
6
by: aj | last post by:
I currently have 2 official DB2 Workgroup Edition licenses for my 2 v8 production servers. I also have tech support/software upgrade agreements in place for both servers. I am interested in...
2
by: Thomas Paul Diffenbach | last post by:
I'm trying to write a space efficient string (nul terminated array of char), storing the characters directly unless the number of characters is too large to be so stored, and storing a pointer to...
1
by: Wiktor Zychla | last post by:
is it legal to distribute axshdocvw, shdocvw and mshtml.dll with my application? is it legal to distribute Microsoft.mshtml.dll from 'Primary Interop Assemblies' folder (I assume it comes with...
11
by: Alberto Giménez | last post by:
Hi, I've seen some object oriented programming bits out there and i'm not sure if they're legal. For example: struct Object { int field1; int field2; }; struct SubObject { int field1; /*...
2
by: Army1987 | last post by:
Is this program legal C89? /* no headers included */ int main(void) { if (sizeof (exit(0), 0), ((void (* )(int))&exit)( (puts((const char *)"hello, world"), 0) ), 0) {
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.