0

hi can someone give this a quick look over and tell me where im going wrong

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

void main()
{
	struct Rainfall{
		char city[20];
		int month;
		int rainfall;
	};

	Rainfall Rainfallarray[18];
	
	int count=0;

	FILE * readfile;
	readfile=fopen("CityRain.txt","r");
	if(readfile==NULL)
	{
		printf("CityRain.txt failed to open.");
		exit(1);
	}

	printf("CityRain.txt Opened\n");

	while(!feof(readfile))
	{
		fscanf(readfile, "%[^,],%d,%d%*c",Rainfallarray[count].city,Rainfallarray[count].month,Rainfallarray[count].rainfall);
		count++;
		printf("In loop%d",count);
	}





	fclose(readfile);

	system("pause"); //OMG MORE RANDOM COMMENTS
}

im getting

Unhandled exception at 0x6fdde30e (msvcr100d.dll) in Assingment.exe: 0xC0000005: Access violation writing location 0xcccccccc.

2
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by Slavrix
0

Investigate how the *scanf family of functions work. You must provide an address of a variable, not the variable itself.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.