I've been reading similar questions here for hours and I just can't seem to get it. I'm fairly experienced with java, but this is my first program in C. The professor has done absolutely nothing to teach us the relevant skills for this program.
Program Purpose: To read in text lines from a text file one pair at a time and determine whether the first is equal to, greater than, or less than the second based on the ASCII collating sequence. The program will also indicate the character position where the first deviation occurs. The program will process all pairs of lines and then print the total number of pairs processed, the number of equal pairs, the number of first line greater than the second, and the number of pairs with first lines less than second lines.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void readFile(char **strs){
//read strings from file and place them in strs
}
void comparePairs(char *strs, int *nums){
//compares pairs of strings according to ASCII collating sequence,
//printing strings as it goes. Also prints the position of the first deviation
//between a pair, if there is any.
//returns numPairs, numEqual, numGreater, and numLesser
int numPairs = 0;
int numEqual = 0, numGreater = 0, numLesser = 0;
nums[0] = numPairs;
nums[1] = numEqual;
nums[2] = numGreater;
nums[3] = numLesser;
}
void printResults(int numPairs, int numEqual, int numGreater, int numLesser){
printf("%d pairs were processed.\n", numPairs);
printf("%d equal pair(s).\n", numEqual);
print("%d greater pair(s).\n", numGreater);
print("%d less than pairs(s).\n", numLesser);
}
int main(){
char strs[100][1000];//strings from file (max 100 strings, each of max size 1000)
char (*ptrStrs)[1000];
ptrStrs = strs;
int nums[4] = {0,0,0,0};//contains numPairs, numEqual, numGreater, and numLesser
int numPairs = 0;//the total number of pairs processed
int *ptrNumPairs = &numPairs;
//the number of pairs where the first line is equal to, greater than, or lesser
//than the first line respectively
int numEqual = 0, numGreater = 0, numLesser = 0;
int *ptrNumEqual = &numEqual, *ptrNumGreater = &numGreater, *ptrNumLesser = &numLesser;
readFile(**strs);
comparePairs(strs, nums);
printResults(nums[0], nums[1], nums[2], nums[3]);
return 0;
}
I'm getting many errors, but the first is passing argument 1 of 'readFile' makes pointer from integer without a cast
. Any help at all with making some headway with this would be greatly appreciated.