Printf n'est pas connue en ubuntu

Bonjour,
je veux lancer du code c sur le terminal de ubuntu bootable "Live"
voila le code d'erreur lors de la commande [ gcc zied.c ]
ubuntu@ubuntu:~/Desktop$ gcc zied.c
zied.c: Dans la fonction «main» :
zied.c:3: attention : incompatible implicit declaration of built-in function «printf»

alors que mon fichier zied.c contient simplement ca :

main()
{
printf("coucou !");
}
Configuration: Linux
Firefox 3.0

11 réponses

  • Votes
  • Date
  • Date décroissante
  1. remarque pour que gcc fonctionne j'ai fais la commande suivante :
    sudo aptitude install build-essential
    1. la meme chose :
      ubuntu@ubuntu:~/Desktop$ gcc zied.c
      zied.c: Dans la fonction «main» :
      zied.c:4: attention : incompatible implicit declaration of built-in function «printf»
      1. peut etre qu'on doit faire quelque chose pour que printf soit reconnue par ubuntu
        une cde linux comme la precedente
        1. verifions mon code linux :

          #include <stdlib.h>
          main()
          {
          printf("coucou !");
          }
          1. le prob que j'utilise un cd bootable ubuntu sinon je n'aurais pas de prob
            1. #include <stdlib.h>

              int main (int argc, char * argv[])
              {

              puts ( "Hello world!" ) ;

              return EXIT_SUCCESS ;
              }
              1. gcc fonctionne :
                ubuntu@ubuntu:~/Desktop$ gcc zied.c
                ubuntu@ubuntu:~/Desktop$ zied.c
                bash: zied.c : commande introuvable
                mais comment executer ce fichier ?
                1. Modérateur
                  Salut,

                  c'est stdio.h que tu dois utiliser
                  il suffit de regarder man 3 printf
                  PRINTF(3)                                                                         Manuel du programmeur Linux                                                                         PRINTF(3)
                  
                  NOM
                         printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf, vsnprintf - Formatage des sorties
                  
                  SYNOPSIS
                         #include <stdio.h>
                  


                  Si tu fait gcc zied.c alors le fichier exécutable crée par défaut sera a.out voir man gcc pour plus de détails
                   -o file
                             Place output in file file.  This applies regardless to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or prepro-
                             cessed C code.
                  
                             If you specify -o when compiling more than one input file, or you are producing an executable file as output, all the source files on the command line will be compiled at once.
                  
                             If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in source.o, its assembler file in source.s, and all preprocessed C
                             source on standard output.
                  
                  Ce qui veut dire que dans ton cas il faut faire
                  gcc zied.c
                  ./a.out