Take the 2-minute tour ×

Working on a problem where I have to read data from a file into a struct using .

The file is organized so that there is a name, a few lines of ASCII art terminated by a # and a rating. Here is an example

Sample Name
( S )
( S )
# 5

I have my struct set up like this:

typedef struct
   char* name;
   char* art;
   int rating;

When I compile my source, I keep getting the following warnings:

multiple-character character constant
overflow in implicit constant conversion

on this line buffer[artCount] = '/0'; where artCount is strlen of the buffer itself.

I'm simply adding a null character to the end of a character array to prepare for a strcpy. Is there something wrong with my logic here?


/*CASE* all is an empty array of CASE structs*/
void readFile(FILE* FPin, CASE* all)
  CASE* walker = all;
  int count = 0;
  int artCount;
  char buffer[160];

  if((FPin = fopen("art.txt", "r")) == NULL)
    printf("Error opening file.");

 walker->name = (char*)malloc(sizeof(char)*100);

 /*Reads in the name*/
 while(fgets(walker->name, 100, FPin) != NULL)

 /*Reads in the art*/
   while(fscanf(FPin, "%c", buffer) != '#');

   artCount = strlen(buffer);
   buffer[artCount] = '/0';
   walker->art = (char*)malloc(sizeof(char)*160);
   strcpy(walker->art, buffer);

/*Reads in the rating*/

     fscanf(FPin, "%d", &walker->rating);


share|improve this question
The escape sequence is \0backslash zero –  sidyll Apr 23 '12 at 21:45
sizeof(char) is guaranteed to be 1 by the C standard. –  Adam Rosenfield Apr 23 '12 at 21:45
add comment

1 Answer

up vote 9 down vote accepted

The constant should be '\0' (with a backslash), not '/0' (with a forward slash).

share|improve this answer
add comment

Your Answer


