Donc j'écris ce programme, et je ne sais pas comment passer par référence ou valeur. J'ai juste besoin de passer des valeurs d'une fonction (processFile) à une autre fonction (printReport). Toute aide sur la façon de le faire serait appréciée.C passant et pointeurs
#include <stdio.h>
#include <stdlib.h>
void printInstructions();
int processFile(FILE *fileIn);
void printReport();
int main(void)
{
FILE *fileIn;
int words = 0,
lines = 0,
characters = 0,
sentences = 0;
printInstructions();
fileIn = fopen("input09.txt", "r");
if(fileIn == NULL)
printf("\n\nERROR\n\n");
processFile(fileIn);
printReport(words, lines, characters, sentences);
}
void printInstructions()
{
printf("\n Program reads a file and returns the number of \n");
printf("lines, words, characters, and sentences in the file.\n\n");
return;
}
int processFile(FILE *fileIn)
{
int sentences = 0,
words = 0,
lines = 0,
characters = 0,
ch;
while(ch != EOF)
{
ch = fgetc(fileIn);
if(ch == '\n' || ch == 60)
lines++;
if(ch == '.')
sentences++;
if(ch != '.' || ch != ' ' || ch != '\n')
characters++;
if(ch == ' ')
words++;
}
return 0;
}
void printReport()
{
printf("This file contains NUMBER lines.\n");
printf("This file contains NUMBER words.\n");
printf("This file contains NUMBER characters.\n");
printf("This file contains NUMBER sentences.\n\n");
return;
}