Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7827569
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T09:56:33+00:00 2026-06-02T09:56:33+00:00

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

  • 0

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;
 }CASE;

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?

function:

/*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.");
    exit(100);  
  }

 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);

   count++;
   walker++;
 } 

  fclose(FPin);
  return;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T09:56:34+00:00Added an answer on June 2, 2026 at 9:56 am

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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a problem where I have to read data from a file into
I have a problem that I had working in a test but now in
I have some code that allows users to upload file attachments into a varbinary(max)
The app I am working on needs to read a JSON file that may
I want to read all rows in a table using system.data.sqlite. As I have
Is there a way to read a file's data but continue reading the data
I am trying to read in data from a text file (the time). and
I am currently working on Problem 62 I have tried the following code to
I working on project and have problem with threading and update of UI. I
I have a strange problem working with HTML,CSS in different browsers: Firefox 3.6 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.