Advertisement
fouzimedfouni

puts-gets-fputs-fgets Usage

Oct 18th, 2014
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.35 KB | None | 0 0
  1. /* here is the first form for the code below :
  2. *#include <stdio.h>
  3. *main()
  4. *{
  5. *      char name[50];
  6. *      
  7. *    
  8. *      printf(" fill the info below please .........:\n");
  9. *     printf("enter your name : ");
  10. *     scanf("%[^\n]",name);  * we use this part %[^\n] for writting words with*
  11. *                            
  12. *      printf("my name is : %s  ",name);
  13. *      fflush(stdin);
  14. *      getchar();
  15. *      
  16. * } ;
  17. *
  18. *
  19. *
  20. */
  21.  
  22.  
  23. #include <stdio.h>
  24. main()
  25. {
  26.       char name[50];
  27.       /* puts  = printf   (but with some differences )
  28.       * gets  = scanf   (but with some differences )
  29.       * there is more functions like "fputs , fgets" but they are little bit different from the ones above
  30.       * FOR MORE INFORMATION AND EXPLANATION BACK TO "C Programming Tutorial 44 - Strings and Characters " tutorial
  31.       */
  32.      
  33.       puts(" fill the info below please .........:"); /*you dont need to insert the "\n"to back to the new line*/
  34.       puts("enter your name:");/*you dont need to insert the "\n"to back to the new line*/
  35.       gets(name); /*you dont need to use the variable "%"symbol or the typeor the variable */
  36.       puts ("my name is :"); /*you dont need to insert the "\n"to back to the new line*/
  37.       puts(name); /*here I am printing out the value of the variable "name" */
  38.       fflush(stdin);
  39.       getchar();
  40.  
  41.       } ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement