0

I am trying to convert my 'char' to a 'string'. I have tried looking it up online, but to no avail. Any suggestions?

1

A string is an array, therefore you can access it using brackets and the number of the place you want to put the char.

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

int main(void)
{
    char letter = 'y';
    string letterConvert = malloc(sizeof(char)*10);
    letterConvert[0] = letter;
    printf("%s\n", letterConvert);
}
1
  • Thank you so much :)
    – Jason_V
    Feb 9 '17 at 5:08

You must log in to answer this question.

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