• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Help with simple C program
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Help with simple C program


  • Subject: Help with simple C program
  • From: Isaac Rivera <email@hidden>
  • Date: Sat, 4 Sep 2004 18:54:00 -0400

When running the program below and entering the path to file which
contains the following text:

This is a test...

I get the pipe characther "|" as a result. This is true if I read
additional characters. They all print to "|".

I wrote the text file named "copyme" in pico.

Thanks!

Isaac

//	Read characters from a file:
#include <stdio.h>
int main (void)
{
	char inName[64];
	FILE *in;
	int c;

	//	get file names from the user;
	printf("\nEnter the name of the file to be copied: ");
	scanf("cs", inName);
	//	open input and output files:
	if((in = fopen(inName, "r")) == NULL)
	{
		printf("Can't open %s for reading.\n", inName);
		return 1;
	}

	//	get the first character of in:
	c == getc(in);
	printf("c = %c\n", c);
	//	Close open files:
	fclose(in);

	return 0;
}
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Help with simple C program
      • From: Fritz Anderson <email@hidden>
References: 
 >Run Log message (From: Dick Roberts <email@hidden>)

  • Prev by Date: Re: Run Log message
  • Next by Date: Re: Help with simple C program
  • Previous by thread: Re: Run Log message
  • Next by thread: Re: Help with simple C program
  • Index(es):
    • Date
    • Thread