Define string constant with #define - C Preprocessor

C examples for Preprocessor:Preprocessor Operators

Introduction

The %s tells printf() to print a string.

Demo Code

#include <stdio.h>

#define PRAISE "this is a test."

int main(void)
{
    char name[40];
    /*w  ww  .ja va  2s. c o m*/
    printf("What's your name? ");
    scanf("%s", name);
    printf("Hello, %s. %s\n", name, PRAISE);
    
    return 0;
}

Result


Related Tutorials