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 4583006
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:09:17+00:00 2026-05-21T21:09:17+00:00

Hello I am teaching myself C and going through the K & R book

  • 0

Hello I am teaching myself C and going through the K & R book and I am having some trouble (I am running OS X). This is from section 1.5.1 “File Copying” which is supposed to take a character as input, then output the character. Here is the code:

#include <stdio.h>

/* --  Copy input to output -- */ 
int main(void)
{
int c;

c = getchar();

while ( c != EOF ) {
    putchar(c);
    c = getchar;
}


}

So, I think my problem is not with the code itself but with compling and running. First of all, when compiling I get the following errors

/Volumes/Goliath/Dropbox/C programs/prog1_5_1.c: In function ‘main’:
/Volumes/Goliath/Dropbox/C programs/prog1_5_1.c:12: warning: assignment makes integer from pointer without a        cast
/Volumes/Goliath/Dropbox/C programs/prog1_5_1.c:16: warning: control reaches end of non-void function

Then when I run the output file (in terminal) it has a small space, then when I input a letter, say I type

a

then I hit Return

and I get a new line. If I then hit a new key, the screen starts going crazy with question marks all over the place.

I am not sure if I am making much sense but I am finding this an odd problem to have. Thank you very much in advance

  • 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-21T21:09:18+00:00Added an answer on May 21, 2026 at 9:09 pm

    The second assignment should be c = getchar();. By leaving out the parentheses, you’re assigning the address of the getchar function to c, which is very much not what you want.

    Also, at the end of main you need the line return 0; or similar in order to get rid of the “control reaches end of non-void function” warning.

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

Sidebar

Related Questions

Hello I need some help understanding what is going on in this assembly code:
Hello I am having this problem . I have the image for the problem.
hello I am trying to create a text file that will then store some
I have started teaching myself about the Android NDK and I have followed this
Hello: I am teaching myself Linq to Sql in C#. Because I am using
Hello all I am working on html and javascript.And I am going to ask
Hello I have like this 2 tables class User public int UserId{get;set;} { ....
Hello I've got this query to get users by email, which is an unique
I've been teaching myself python and cgi scripting, and I know that your basic
I'm a Python(3.1.2)/emacs(23.2) newbie teaching myself tkinter using the pythonware tutorial found here .

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.