Pass the address of a string to puts() - C String

C examples for String:String Function

Description

Pass the address of a string to puts()

Demo Code

#include <stdio.h>
#define DEF "I am a #defined string."
int main(void)
{
    char str1[80] = "An array was initialized.";
    const char * str2 = "A pointer was initialized.";
    /*from  ww w. j  a  v  a2s  .c  om*/
    puts("I'm an argument to puts().");
    puts(DEF);
    puts(str1);
    puts(str2);
    puts(&str1[5]);
    puts(str2+4);
    
    return 0;
}

Result


Related Tutorials