Basically, I'm writing some code that will take text from some .txt files and rearrange them into other .txt files. I've written 3 functions, but ignore the 2nd one, I haven't worked on it yet. When I try to call my 3rd function, I get an error message from Dev C++ saying "Called object is not a function". I know it's the context of my whole program, because I have run the function in a different program, and it works fine. If anyone could narrow down the problem for me, I would appreciate it VERY much. The line of code that gets highlighted by Dev C++ is in red, scroll down until you see it.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
/* This function searches for a keyword in a line, if the keyword
is found, it returns the position in the line array that the
match was found, otherwise, it returns -1. The "wild" character
acts just like a blank tile in scrabble(for the keyword)
*/
int line_search(char keyword[], char line[], char wild);
/* This function filters out whatever string is put in as the char
array leave_out.
*/
char *filter(char input[], char leave_out[]);
/* This function gets every paragraph up to the on that has the
predefined delimeter character or phrase. It returns a number
array with the 0th term being the number of paragraphs
*/
int slide(FILE *ifp, char delimeter[], char wild);
char paragraph_list[50][80][250], dummy[10], stitle[50][40];
int format;
int main(){
FILE *ifp, *ofp;
int templete;
int isimage, topnum, bottomnum, newslide, body;
int i, j, k, l, m, n, folder, index, contin = 0, a;
char course[20], path[100];
char temp[250], file[60][10000], stitle[100], ptitle[100];
char slide[20], top[100][1200], bottom[100][1200], paragraph[50][250], input[250];
char base[100];
char base2[10000], temp1;
char filename [ FILENAME_MAX ];
//Here is where the user is given options
printf("Enter the the number corresponding with the folder the images and videos will be stored in:\n");
printf("1 t2/images\n2 system32\n\n");
scanf("%d", &folder);
printf("\n\nPlease put the number that corresponds with the slides subject, and press enter:\n1 Math\n2 Literature\n3 Science\n4 Social Sciences\n\n");
scanf("%d", &templete);
printf("\nEnter the course name\n");
gets(dummy);
gets(course);
printf("How are the slide numbers formatted?\n");
printf("1) #.#.#- SLIDE #\n");
printf("2) #.#.#- <Title>\n");
scanf("%d", &format);
//Here is where the image path is created. More paths may be created
char imaget2[210] = "../../LMS/Content/Sections/t2/images/";
char imagesystem32[220] = "../../LMS/Content/Sections/system32/";
if(folder == 1)
strcpy(path, imaget2);
else if(folder == 2)
strcpy(path, imagesystem32);
strcat(path, course);
// printf("\n\nCreate a new folder here: \"%s\"\n\nGive it the exact same name as the folder that was created when you saved the document as a webdoc.\n\nThis will be where you upload images; Do not rename them\n\n", &path);
// system("pause");
//Here, we open up the template to be used
if(templete==1) //Math
ifp = fopen("Modified_MATH.txt", "r");
else if(templete==2) //Literature
ifp = fopen("Modified_LIT.txt", "r");
else if(templete==3) //Science
ifp = fopen("Modified_SCI.txt", "r");
else if(templete==4) //Social Studies
ifp = fopen("Modified_SS.txt", "r");
//Scan the top part of the template
strcpy(top[0], "test");
i=0;
while(strlen(top[i])!= 0){
i++;
fscanf(ifp, "%[^\n]%c", top[i], temp);
}
topnum = i;
fscanf(ifp, "%c", temp);
//And scan the bottom part of the template
strcpy(bottom[0], "spotholder");
i=0;
while(strlen(bottom[i])!= 1){
i++;
fscanf(ifp, "%[^\n]%c", bottom[i], temp);
strcat(bottom[i], " ");
}
bottomnum = i;
fclose(ifp);
//for(i=1; i<topnum; i++)
//printf("%s",top[i]);
//system("pause");
ifp = fopen("doc.txt", "r");
//This loop goes through each slide:
//It knows to go to the next slide when the delimeter is hit
newslide = 0;
while(newslide == 0){
//This line is necessary to get into the while loop up ahead
strcpy(temp,"tits");
//Scan whole paragraph
while(strlen(temp)!= 0){
memset( temp, '\0', 250 );
//Here, a line is scanned, and entered into temp, while the
//dummy char eats the '\n'
fscanf(ifp, "%[^\n]%c", temp, dummy);
//Here is where each format
if(format==1){
if (line_search("SLIDE", temp, ' ')!=-1){
printf("\n\nSLIDE found!!!!!");
newslide = 1;
}
a = line_search("SLIDE", temp, ' ');
printf("%d=|%s| %d",i,temp,a);
}
}
fscanf(ifp, "%c", temp);
printf("\nNew Paragraph");
system("pause");
}
fclose(ifp);
ifp = fopen("doc.txt", "r");
//THIS LINE RIGHT HERE GIVES ME THE ERROR MESSAGE
a = slide(ifp, "SLIDE",' ');
printf("a = %d",a);
getchar();
fclose(ifp);
for(i=0;i<a;i++){
for(j=0;j<80;j++){
printf("paragraph_list[%d][%d]=|%s|", i,j,paragraph_list[i][j]);
}
system("pause");
}
}
//This function searches for a keyword in a line, if the keyword is found, it returns the
//position in the line array that the match was found, otherwise, it returns -1.
//The "wild" character acts just like a blank tile in scrabble(for the keyword)
int line_search(char keyword[], char line[], char wild) {
int i, j, key_length, line_length, k=0;
key_length = strlen(keyword);
line_length = strlen(line);
for(i=0; i<=(line_length-key_length); i++){
for(j=0; j<key_length; j++){
if (line[i+j]==keyword[j]||wild==keyword[j]){
k++;
printf("k=%d\n",k);
}
else{
k=0;
break;
}
}
if(k==key_length)
return i;
}
printf("\n");
return -1;
}
/* This function filters out whatever string is put in as the char
array leave_out.
*/
//Edit this
char *filter(char input[], char leave_out[]){
int i, j, leave_out_length, input_length, k=0;
leave_out_length = strlen(leave_out);
input_length = strlen(input);
for(i=0; i<=(input_length-leave_out_length); i++){
for(j=0; j<leave_out_length; j++){
if (input[i+j]==leave_out[j]){
k++;
printf("k=%d\n",k);
}
else{
k=0;
break;
}
}
if(k==leave_out_length)
return "i";
}
printf("\n");
return "asd";
}
/* This function gets every paragraph up to the on that has the
predefined delimeter character or phrase. It returns a number
array with the 0th term being the number of paragraphs
*/
int slide(FILE *ifp, char delimeter[], char wild){
int newslide = 0, paragraph_number = 0, line_number, a;
int i,j,k;
for(i=0;i<50;i++){
for(j=0;j<80;j++){
memset(paragraph_list[i][j], '\0', 250 );
}
}
//This loop grabs every paragraph until the new slide delimeter is found
while(newslide == 0){
//The very first line of each paragraph will have some string in it,
//so the initial strlen(char** paragraph_list) will be non-zero, and
//the while loop ahead will run
strcpy(paragraph_list[paragraph_number][0], "tits");
//Scan whole paragraph
line_number=0;
while(strlen(paragraph_list[paragraph_number][line_number])!= 0){
//The line_number has to be incremented, because the lines in
//the paragraph will start at line_number 1
line_number++;
//Here, a line is scanned, and entered into the 3d paragraph
//array, while the dummy char eats the '\n'
fscanf(ifp, "%[^\n]%c", paragraph_list[paragraph_number][line_number], dummy);
printf("Paragraph%d,line%d(a=%d)=\n|%s|",paragraph_number, line_number, a, paragraph_list[paragraph_number][line_number]);
if(format==1){
if (line_search(delimeter, paragraph_list[paragraph_number][line_number], wild)!=-1){
printf("SLIDE found\n\n");
newslide = 1;
}
a = line_search(delimeter, paragraph_list[paragraph_number][line_number], wild);
}
}
fscanf(ifp, "%c", dummy);
paragraph_number++;
printf("\nNew Paragraph");
system("pause");
}
printf("out of the loop!");
system("pause");
return paragraph_number;
}
Thanks,
Matt