Jump to content

Recommended Posts

Hey I don't quite grasp the idea of using %d as in:

 

scanf ( "%d", &units ); 

or in

printf( "%d Units", unit);

 

Its exactly the same as in php. Take a look at sprintf.

 

Also, does anybody have any good recommendations for sites like this covering C?

 

You might try here.

Link to comment
https://forums.phpfreaks.com/topic/87695-solved-c-question/#findComment-448568
Share on other sites

  • 4 weeks later...
  • 1 month later...

in the case of

 

scanf("%d", &units);

 

%d is saying to expect an integer.

 

others are %f for float, double and %c for char but there are more

 

 

in the case of

printf("%d Units", unit);

 

thats to say where you want the integer to be displayed

 

 

take your phone number for example

 

to print (XXX) XXX-XXXX, you can do that in one line of code:

printf("(%d) %d-%d", areaCode, exchange, phNum);

Link to comment
https://forums.phpfreaks.com/topic/87695-solved-c-question/#findComment-502634
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.