Aller au contenu principal
ProduitsOutils de bureauTASTECADConsultation de plansTASTEFILESGestion de fichiersTASTEFTPTransfert de fichiersTASTESSHEspace de travail à distanceTASTEZIPCompression et extractionTASTEWINMGestion de fichiersOutils pour développeursTASTECODEEnvironnement de développement intégré pour RustTASTESTUDIOEnvironnement intégré de développement et de testTASTEETLIntégration de données (ETL)ServeursTASTEREMOTEServeur de bureau à distanceTASTEGEOServeur géospatialTASTEMAILEspace de travail e-mailInvestissementTASTESTOCKApplication de bureau de trading automatique d'actionsCommencerTéléchargementsDocumentationAcheterTous les produits
Marketplace
Actualités
TechActualitésL’actu dev du jourDocs développeursLangages de programmationRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartFrameworks front-end webNext.jsReactVue.js · NuxtSvelteKitAngularFrameworks serveurSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressFrameworks d'applications et de bureauTauriFlutterReact NativeElectronAlgorithmesBases des algorithmesAlgorithmes essentielsAlgorithmes avancésAlgorithmes pratiques
CommunautéProjetsJournaux de développementPromptsProblèmes d’outils d’IAVitrineGuide de la communauté
CollaborerTransfert techniqueRéalisation de site webRéalisation d'application de bureauChaîne de publication et de paiementPartenaire commercialContact
ServicesBureau à distancePaquets d'installation sur mesure
TASTEDEV
Produits

Outils de bureau

TASTECADDes plans complexes, ouverts en toute légèretéTASTEFILESSeulement les fichiers utiles, au plus viteTASTEFTPLe chemin le plus net pour vos fichiersTASTESSHEntre vos serveurs et vous, un lien plus solideTASTEZIPCompresser plus vite, extraire en toute sécuritéTASTEWINMUn gestionnaire de fichiers à deux volets, pensé pour le clavier

Outils pour développeurs

TASTECODEModifier, compiler, déboguer et tester vos apps Rust dans une seule fenêtreTASTESTUDIODe l’édition aux tests à distance et aux corrections IA approuvéesTASTEETLDéplacer les données, les valeurs sous les yeux

Serveurs

TASTEREMOTEUn bureau à distance hébergé sur votre propre serveurTASTEGEOUn serveur géospatial compatible GeoServer, reconstruit en RustTASTEMAILReprenez la maîtrise de vos e-mails

Investissement

TASTESTOCKDu trading automatique d'actions selon vos règles : quand, et quoi

Commencer

TéléchargementsDernières versions de chaque produitDocsUtiliser chaque produitAcheterAbonnements et licences perpétuellesTous les produitsTous les produits en un coup d’œil
Tous les produits
MarketplaceActualités
Tech

Actualités

L’actu dev du jourAnnonces officielles : langages, frameworks, GitHub et IADocs développeursGuides des langages, frameworks et algorithmes

Langages de programmation

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Frameworks

Frameworks front-end webNext.jsReactVue.js · NuxtSvelteKitAngular
Frameworks serveurSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
Frameworks d'applications et de bureauTauriFlutterReact NativeElectron

Algorithmes

Bases des algorithmesAnalyse de complexité · Tri · Recherche · Structures de données de base · Arbres et tasAlgorithmes essentielsParcours de graphe · Plus courts chemins et arbres couvrants · Programmation dynamique · Algorithmes gloutons · Diviser pour régner · Backtracking (retour sur trace)Algorithmes avancésAlgorithmes sur les chaînes · Mathématiques et théorie des nombres · Manipulation de bits · Arbres de segments · Union-FindAlgorithmes pratiquesStratégie pour les entretiens de codage · Cache LRU · Limitation de débit · Hachage cohérent
Toute la documentation de développement
Communauté
ProjetsDécouvrir les créateurs et leurs travauxJournaux de développementDécisions et enseignementsPromptsInstructions réutilisablesProblèmes d’outils d’IAProblèmes et contournements de Claude, Codex, GeminiVitrineRéalisations terminéesGuide de la communautéConstruire en toute transparence
Collaborer
Transfert techniqueApplications natives en Rust et eguiRéalisation de site web10 langues, comptes, documentation et téléchargementsRéalisation d'application de bureauRust et egui, sans WebViewChaîne de publication et de paiementSignature, MSI, deb, rpm, AppImage, empreintesPartenaire commercialRecommandez-nous, touchez 30 %ContactDéveloppement, partenariats, investissement
Services
Bureau à distanceAccédez à votre ordinateur depuis le navigateurPaquets d'installation sur mesureSeulement l'utile, réglages préchargés
Acheter
FR
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Se connecter
Se connecter
TASTEDEV

Des petits outils à un meilleur développement.

support@tastedev.netSoutenir TASTEDEV
ProduitsGamme de produitsAcheterDocsTéléchargementsMarketplaceAssistance
CommunautéProjetsJournaux de développementPromptsProblèmes d’outils d’IAVitrine
RèglesÀ proposPolitique de confidentialitéConditions d'utilisationConditions d’abonnementRemboursementRègles de la communauté
CompteSe connecterS'inscrire
Visiteurs
Aujourd’hui
Hier
Vues au total
Société
GXSOFT
Représentant
CHOI YOUNG GU
Numéro d’enregistrement
853-44-00368
Adresse
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Téléphone
+82-10-4404-1523
E-mail
whitecalvin@tastedev.net
Responsable de la confidentialité
CHOI YOUNG GU

© 2026 TASTEDEVLes informations produit s'appuient sur des sources de développement vérifiées.Publié · en amélioration

Documentation C
C
Getting StartedSyntax BasicsTypes and DataModules and LibrariesErrors and TestingKey Concepts: Pointers and Memory
Discussions

Guide C · 2/6

Syntax Basics

Ce chapitre n'est disponible qu'en anglais pour le moment.

C has a small, compact syntax, and most of it fits on a page. This chapter covers the entry point main, variables and operators, functions and prototypes, control flow, and basic console I/O with printf and scanf.

The main function

Every C program begins in main. The standard guarantees two signatures:

#include <stdio.h>

int main(int argc, char *argv[]) {
    printf("argument count: %d\n", argc);
    for (int i = 0; i < argc; i++) {
        printf("argv[%d] = %s\n", i, argv[i]);
    }
    return 0;
}

If you do not need command-line arguments, write int main(void). argc is the number of arguments and argv holds them as strings; argv[0] is usually the program name. Falling off the end of main is treated as return 0, but being explicit reads better.

Variables and operators

Variables are declared with a type before use. Since C99 you can declare them anywhere in a block, including inside a for header. Local variables start with an indeterminate value, so initialize them where you declare them.

int count = 0;
double ratio = 0.75;
const int max_users = 100;   /* read-only */

int a = 7, b = 2;
int q = a / b;               /* 3: integer division truncates toward zero */
int r = a % b;               /* 1: remainder */
double d = (double)a / b;    /* 3.5: convert one operand to get real division */

count += 5;                  /* same as count = count + 5 */
count++;                     /* increment by one */

The operators you will use most:

  • Arithmetic: +, -, *, /, %
  • Comparison: ==, !=, <, <=, >, >=, which yield an int that is 1 or 0
  • Logical: &&, ||, !, which short-circuit, so the right side is skipped when the left side decides the result
  • Bitwise: &, |, ^, ~, <<, >>
  • Assignment: =, +=, -=, *=, /=, and friends

In C, zero is false and any non-zero value is true. Include <stdbool.h> to get bool, true, and false (C23 makes them proper keywords). A classic slip is writing if (x = 0), which assigns instead of comparing; -Wall warns about it.

Functions and prototypes

Des questions sur ce chapitre ?
Chapitre précédentGetting StartedChapitre suivantTypes and Data

A function has a return type, a name, and a parameter list. The compiler reads a file top to bottom, so calling a function before its definition requires a prototype (a declaration) earlier in the file.

#include <stdio.h>

/* prototypes: tell the compiler these functions exist */
int max_of(int a, int b);
void greet(const char *name);

int main(void) {
    greet("C");
    printf("%d\n", max_of(3, 9));
    return 0;
}

int max_of(int a, int b) {
    return a > b ? a : b;
}

void greet(const char *name) {
    printf("Hello, %s!\n", name);
}

Arguments are always passed by value: the function gets a copy, and changing a parameter does not affect the caller. To let a function modify the caller's variable, you pass a pointer, which chapter 6 covers in depth. For a function that takes no arguments, write int f(void); that is what states "no parameters" precisely.

Control flow

C offers if/else, switch, while, do-while, and for, plus break to leave a loop and continue to jump to the next iteration.

for (int i = 1; i <= 15; i++) {
    if (i % 15 == 0) {
        printf("FizzBuzz\n");
    } else if (i % 3 == 0) {
        printf("Fizz\n");
    } else if (i % 5 == 0) {
        printf("Buzz\n");
    } else {
        printf("%d\n", i);
    }
}

int day = 6;
switch (day) {
case 6:
case 7:
    printf("weekend\n");
    break;          /* without break, execution falls into the next case */
default:
    printf("weekday\n");
    break;
}

int n = 0;
do {
    n++;
} while (n < 3);    /* the body always runs at least once */

switch works only on integer values. Forgetting break makes execution fall through to the following case, so end every case with break unless fall-through is deliberate.

printf and scanf

printf substitutes its arguments into the conversion specifiers of a format string. A specifier that does not match the argument type is undefined behavior, so match them carefully.

SpecifierTypeExample
%dintprintf("%d", 42)
%ldlongprintf("%ld", 42L)
%uunsigned intprintf("%u", 7u)
%zusize_tprintf("%zu", sizeof(int))
%fdoubleprintf("%.2f", 3.14159)
%ccharacterprintf("%c", 'A')
%sstringprintf("%s", "text")
%ppointerprintf("%p", (void *)&x)

scanf stores what it reads, so it needs the address of each variable (&). It returns the number of items successfully converted, and you should always check it. Note that scanf reads a double with %lf, unlike printf.

#include <stdio.h>

int main(void) {
    int age;
    double height;

    printf("Enter age and height: ");
    if (scanf("%d %lf", &age, &height) != 2) {
        fprintf(stderr, "invalid input\n");
        return 1;
    }
    printf("age %d, height %.1f\n", age, height);
    return 0;
}

For reading a line of text, prefer fgets(buf, sizeof buf, stdin), which respects the buffer size. A bare %s has no length limit and can overflow the buffer.

Summary

  • Programs start at int main(void) or int main(int argc, char *argv[]).
  • Declare variables with a type and initialize them immediately; integer division discards the fraction.
  • Put prototypes before calls to functions defined later. Arguments are passed by value.
  • End switch cases with break.
  • Match printf specifiers to argument types exactly and always check what scanf returns.

0 commentaire

Meilleurs commentairesPlus récents d'abord

Se connecter · Connectez-vous pour laisser un commentaire.