How to print a variable inside quotation marks in C

3 Answers

0 votes
#include <stdio.h>

// String Variable

int main(void)
{
    char name[] = "Neo";

    printf("\"%s\"\n", name);

    return 0;
}


/*
run:

"Neo"

*/

 



answered Oct 10 by avibootz
0 votes
#include <stdio.h>

// Integer Variable

int main(void)
{
    int age = 25;

    printf("\"%d\"\n", age);

    return 0;
}


/*
run:

"25"

*/

 



answered Oct 10 by avibootz
0 votes
#include <stdio.h>

// Character Variables
int main(void)
{
    char ch = 'A';

    printf("\"%c\"\n", ch);

    return 0;
}


/*
run:

"A"

*/

 



answered Oct 10 by avibootz
...