I probably miss something very obvious here. I have a simple program (code below), which gives me error: "format specifies type 'char *' but the argument has type 'char'". I tried changing it to char but this caused a bunch of other errors. Could you please give me a hint here? Code:

#include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <ctype.h>

int main(void)
    string s = get_string(); //Hello, World
    printf ("Example %s", s[0]); //trying to access "Hello" - the 0th element

1 Answer 1


You're right, it's something simple. %s is the placeholder for printing a string. %c is for printing a character. The variable s is for a string, but s[0] is a character, not a string. In this case, %c should be used.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .