Mathc initiation/Fichiers c : c01k

Un livre de Wikilivres.


Sommaire


Installer et compiler ces fichiers dans votre répertoire de travail.

c01j.c
/* ------------------------------ */
/*  Save as :   c01k.c            */
/* ------------------------------ */
#include    <stdio.h>   
#include    <ctype.h>                                        
#include      "z_s.h"                                            
/* ------------------------------ */
int main(void)
{
char name[] = "\"Xhunga\"";

 clrscrn();

 printf(" To print a back slash into a string,  \n"
        " you must type \\\\ instead of \\. \n\n\n"

        " To print a quotation mark into a string,\n"
        " you must type \\\" instead of \".   \n\n\n" 

        " To print a percentage sign into a string,\n"
        " you must type %%%% instead of %%.    \n\n\n" 

        " My name is \\ %s \\.  a%%b = c\n",name);

 stop();

 return 0;
}
/* ------------------------------ */
/* ------------------------------ */


Pour imprimer certain caractères déjà utilisés par le langage c, il faut utiliser ces méthodes.

  • Pour le back slash \, il faut le doubler \\
  • Pour les guillemets, il faut les précéder d'un back slash \"
  • Pour le signe pourcentage, il faut le doubler %%


Exemple de sortie écran :

 To print a back slash into a string,  
 you must type \\ instead of \. 


 To print a quotation mark into a string,
 you must type \" instead of ".   


 To print a percentage sign into a string,
 you must type %% instead of %.    


 My name is \ "Xhunga" \.  a%b = c

 Press return to continue.