Thanks for at least reading.

My assignment is to prompt for a filename, change the contents to caps, and print. I have the following, and it's giving me the error at line 25 (the inside loop)

Assignment makes integer from pointer without a cast

What does that mean, and how can I get rid of it?


int filechar(char []);

int main()

	FILE *inFile;
	char filename[13], line[256];

	int numchar, i;
	printf("Please enter the name of the file you wish to open:");

	inFile=fopen(filename, "r");
	while (fgets(line,256,inFile) != NULL)
		for (i = 0; line[i] = NULL; i++);
			line[i] = toupper(line[i]);
	fputs(line, inFile);
	printf("%s\n", line);


	return 0;


for (i = 0; line[i] = NULL; i++);

1>Remove the semicolon at the end of this statement.
2>It should be line!=NULL and not line=NULL.

You shouldn't use gets()

So a solution would be:

It seems like a bit too much effort but in the end it's worth the good habits.

#include <stdio.h> 
#include <string.h>
#include <stdlib.h> 
#include <ctype.h>

int main(void)
   char text[20];
   fputs("Please enter the name of the file you wish to open:", stdout);
   if ( fgets(text, sizeof text, stdin) != NULL )
      char *newline = strchr(text, '\n'); /* search for newline character */
      if ( newline != NULL )
         *newline = '\0'; /* overwrite trailing newline */
  FILE *fp;
  char buf[BUFSIZ] = "";
  int i;
  if ((fp = fopen(text, "r")) == NULL)
    perror (text);
    return (EXIT_FAILURE);
  i = 0;

  while (fgets(buf, sizeof(buf), fp) != NULL)
    int k = strlen(buf);
    int m;
    for ( m = 0; m < k; m++ )
This article has been dead for over six months. Start a new discussion instead.