| | I've managed to store the article into heap, but what should I do with the dictionary? I tried using strcpy(tempArticle[i], dictionary); but it didn't seem to work? would someone give ... | mattia FILE *fd; char buf[100]; char fmt[10]; > /* open fd */ sprintf(fmt, "%%%ds", sizeof(buf)-1); while (fscanf(fd, fmt, buf) != EOF) use_word(strdup(buf)); > close(fd); > Is it the best way? What do you think? Define "best"?! It is one way (I'd test fscanf(...) == 1 rather != EOF but that is a small matter) ... | #include #include void main() { FILE *fp; char a,data[100];//Just taking 100 bytes not more that that. int i = 0,count = 0; fp = fopen("C:\\mydoc.txt","r"); // Here my file is stored at C:\ as mydoc.txt clrscr(); if(fp == NULL) { printf("ERROR READING FILE\n"); getch(); exit(0); } else { a = fgetc(fp); while(!feof(fp)) { if(a == ' ' || a ... | So far I have it so that I can open up a file. From there I'm trying to go through the each word of the file and if it starts with an A, I want to throw it into a linked list for words starting with A. So essentially I want to take word #1, if it starts with A or ... | trying to loop through a text file to get a different word each time I use the file So the program is really big so I'll just post the two parts that need to be fixed. The first part is the main function: This version doesn't work right, it asks if the answer was right but then it just gives the ... | Well, your program does compress the text file -- no doubt! Your compression scheme is an odd duck, but OK. To make it work, why not make a text file of about the 100 most popular words in English (and please, only words longer than 1 char ). This info is available on the net, btw. Then read in these words ... | #include "stdafx.h" #include #include #define MAX_LEN_LINE 300 // ? int main() { const char mnemonic[80] = "Mnemonic="; char buffer[MAX_LEN_LINE+2]; char *buff_ptr, *find_ptr; fpos_t position; FILE *fp1, *fp2; size_t find_len = strlen(mnemonic); fp1 = fopen("originalfile.txt","r"); fp2 = fopen("filecreated.txt","w"); while(fgets(buffer,MAX_LEN_LINE+2,fp1)) { buff_ptr = buffer; while ((find_ptr = strstr(buff_ptr,mnemonic))) { fgetpos (fp1, &position); char avoid[]=";"; int i; i = strcspn (buff_ptr,avoid); fsetpos ... | | | #include #include int main(void) { FILE* fin; FILE* fout; char inputfname[256]; char outputfname[256]; char currentchar; char previouschar = ' '; printf("Enter the input filename\n"); scanf("%s", inputfname); printf("Enter the output filename\n"); scanf("%s", outputfname); fin = fopen(inputfname, "r"); fout = fopen(outputfname, "w"); while(!feof(fin)) { currentchar = fgetc(fin); if(!isalpha(previouschar) && isalpha(currentchar)) { currentchar = toupper(currentchar); fputc(currentchar, fout); } currentchar = previouschar; } ... | I am a AD students. I have a question here. does anyone help me? i am writing a program to get word from text file, which is an eassy. i need to sperate each word and then write to another text file. in the new text file, the word should be one word per line , no numbers or other char ... | "America's abundance was created not by public sacrifices to "the common good," but by the productive genius of free men who pursued their own personal interests and the making of their own private fortunes. They did not starve the people to pay for America's industrialization. They gave the people better jobs, higher wages and cheaper goods with every new machine they ... | #include #include #include #include FILE *infile; int main() { int i, j, k, result; char word1[20], word2[50], line[120], word[120], current[50]; int length; printf("Enter the first word to search for: "); gets(word1); printf("Enter the second word to search for: "); gets(word2); infile = fopen("Fruits.txt","r"); if(infile == NULL) { printf("ERROR: Cannot open Fruits.txt"); exit(21); } i=0; while(fgets(line,500,infile)!=NULL){ /*Need to ... |
|