So I am trying to read the words from a file. However, I have to use `putchar(ch)` where `ch` is an `int`. How do I convert ch to a string (char \*) so I can store it in a char \* variable and pass it to another function that takes char \* as a parameter. And I actually just want to store it but not print it.

This is what I have:

```
int main (void)
{
   static const char filename[] = "file.txt";
   FILE *file = fopen(filename, "r");
   if ( file != NULL )
   {
      int ch, word = 0;
      while ( (ch = fgetc(file)) != EOF )
      {
         if ( isspace(ch) || ispunct(ch) )
         {
            if ( word )
            {
               word = 0;
               putchar('\n');
            }
         }
         else
         {
            word = 1;
            putchar(ch);
         }
      }
      fclose(file);
   }
   return 0;
}

```
['https://Stackoverflow.com/questions/31778365', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4807625/']
To represent a single character as a character string, I find using a simple 2-character buffer to be as easy as anything else. You can take advantage of the fact that dereferencing the string points to the first character and simply assign the character you wish to represent as a string. If you have initialized your 2-char buffer to `0` (or `'\0'`) when declared, you have insured your string is always `null-terminated`:

**Short Example**

```
#include <stdio.h>

int main (void) {

    int ch;
    char s[2] = {0};
    FILE *file = stdin;

    while ( (ch = fgetc(file)) != EOF ) {
        *s = ch;
        printf ("ch as char*: %s\n", s);
    }

    return 0;
}

```

**Use/Output**

```
$ printf "hello\n" | ./bin/i2s2
ch as char*: h
ch as char*: e
ch as char*: l
ch as char*: l
ch as char*: o
ch as char*:

```

**Note:** you can add `&& ch != '\n'` to the while condition to prevent printing the newline.
So you have a single value of `char` type, aka `int8_t` (or `uint8_t` on some systems). You have it stored in an `int`, so `fgetc` can return `-1` for error, but still be able to return any 8bit character.

Single characters are just 8-bit integers, which you can store in any size of integer variable without problems. Put them in an array with a zero-byte at the end, and you have a string.

```
char buffer[10] = {0};
int c = 'H';
buffer[0] = c;
// now buffer holds the null-terminated string "H"
buffer[1] = 'e';
buffer[2] = 'l';  // you can see where this is going.
c = buffer[1];  // c = 'e' = 101
  // (assuming you compile this on a system that uses ASCII / unicode, not EBCDIC or some other dead character mapping).

```

Note that the string-terminating zero-bytes got into buffer because I initialized it. Using an array initializer zeroes any elements you don't mention in your initializer list.