
ok i have been making a rainfall code to show town,country, and rainfall. i got most of it but i am having problems with the strings the error keep coming up about adding two pointers.could someone please look at this and tell me what i have wrong without changing the statement too much.
Thank you
~VALerie
Code:
/*Rainfall*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
/*function protoypes*/
FILE *datain;
void CloseFiles(void);
void TownFooter(void);
void CtryFooter(void);
void NewTownBreak(void);
void NewCtryBreak(void);
/*define and initialize variables*/
char Ctry[10], prevCtry[10];
char Town[10], prevTown[10];
int rainfall, stotTown, stotCtry;
/* MAIN PROGRAM */
void main()
{
if ((datain = fopen("e:\\rainfall.txt","r"))== NULL)
{
printf("Cannot open file");
exit(1);
}
system("cls");
printf("\nAnnual Rainfall by Town / Country");
printf("\nTown Country Inches");
printf("\n******************************************************");
fscanf(datain, "\n%s\n%s\n%d",prevCtry,prevTown);
strcpy(prevCtry, Ctry);
strcpy(prevTown, Town);
printf("\nData for the Country of %s", Ctry);
while (strcmp(Town,"prevTown"))
{
stotTown = prevTown+Town
stotCtry = prevCtry+Ctry
gtotal = stotTown+stotCtry
prinf("%s %s %d", Town, Ctry, rainfall);
fscanf(datain, "\n%s\n%s\n%d", stotTown,stotCtry);
if (strcmp(prevCtry) && strcmp(Ctry,"xxxx"))
{
NewCtryBreak();
}
else if (strcmp(prevTown) && strcmp(Town, "xxxx"))
{
NewTownBreak();
}
}
printf("\n Subtotal for %s %s = %d",prevTown, prevCtry, stotTown);
printf("\n\n Subtotal for %s = %d", prevCtry, stotCtry);
printf("\n******************************************************");
printf("\n\nGrandtotal = %d", gtotal);
}
void NewCtryBreak(void)
{
TownFooter();
CtryFooter();
printf("\nData for the Country of %s\n\n", Ctry);
}
void NewTownBreak(void)
{
TownFooter();
}
void CtryFooter(void)
{
printf("\n\n Subtotal for %s = %d", prevCtry, stotCtry);
printf("\n******************************************************\n");
stotCtry = prevCtry+Ctry;
strcpy(Ctry);
}
void TownFooter(void)
{
printf("\n Subtotal for %s %s = %d",prevTown, prevCtry, stotTown);
stotTown = prevTown+Town;
strcpy(Town);
}