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

  • Home
  • SEARCH
  • 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 5970207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:20:29+00:00 2026-05-22T20:20:29+00:00

I wrote a program to fill in closed figures with asterisks. For some reason

  • 0

I wrote a program to fill in closed figures with asterisks.

For some reason it isn’t accepting the sentinel value EOF Ctrl+D.

Why is this?

#include "usefunc.h"

#define height 100
#define width 100

void showRow(int numbers[], int size_numbers) {
    int i;
    printf("[ ");
    for (i = 0; i < size_numbers-3; i++) {
        printf("%c, ", numbers[i]);
  }
    printf("%c ]", numbers[size_numbers-3]);
    printf("\n");
}

void showshape(int shape[][width], int lines, int max_buf) {
    int i, j;
    for (i = 0; i < lines; i++) {
        for (j = 0; j < max_buf; j++) {
            printf("%c", shape[i][j]);
        }
        printf("\n");
    }
}

void fill(int row[][width], int rownum, int end) {
    int i, c = 1, inside = 0;
    for (i = 0; i < end; i++) {
        if (row[rownum][i] == '*') {
            c++;
        }
        if (!(c%2)) inside = 1;
        else inside = 0;
        if (inside) {
            row[rownum][i] = '*';
        }
    }
}

int main () {
    int shape[height][width], i = 0, j = 0, lines = 0;
    int sentinel = 0;
    int temp = 0;
    while (sentinel != EOF) {
        while ((temp = getchar()) != '\n') {
            sentinel = temp;
            shape[i][j] = temp;
            j++;
        }
        i++;
        lines++;
    }
    for (i = 0; i < lines; i++) {
        fill(shape, i, width);
    }
    fill(shape, 0, j);
    //for (i = 0; i < lines; i++)
    showshape(shape, lines, j+2);
}

Edit 1

Just updated the code. It doesn’t quite print the box. what’s going on?


Edit 2

Another update. This time I’m copying the value of temp, however I get

Bus error 

What am i doing wrong?

  • 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-05-22T20:20:29+00:00Added an answer on May 22, 2026 at 8:20 pm

    You want:

    int temp;
    

    EOF is an integer value, not a char.

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

Sidebar

Related Questions

I wrote a java program that should fill a sqlite database with some rows
I wrote a simple program to understand how objective-c works. This program is the
I wrote a program which solves some kind of optimization problem. I have been
I wrote a program to make a graphical Timeline and it works through some
I wrote a Linux program based on a buggy open source library. This library
I wrote a program in C with Ubuntu Linux and now I need to
I wrote a program which includes writing and reading from database. When I run
I wrote a program using AutoIT to fetch information from a number of websites
I wrote a program out, which was all in one file, and the methods
I wrote a quick program in python to add a gtk GUI to a

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.