How to Redesign #include in C?
If you are looking to redesign #include <stdio.h> in C, I will show you a simple way to do it. First, you need to find out what method is used for the file reading and writing functions. The answer is fopen(). To get the fopen() method number and type, you can use the following function:
#include
By Bewildered Butterfly
on Jul 28, 2020
/*
Desperation: This program will have that reports how many lines, words, and characters in an input text file with more than 300 words,
and at least 3 paragraphs, and also makes a sorted list of all words found in it. You are required to provide the text file.
Write the sorted list to an output file, along with the number of times each word appeared in the input file.
For the purpose of this program, a word consists of a consecutive sequence of any characters except white space characters
Programmer: Atifa Masoudi
Programmer ID: 156308199
Date:07/09/2020
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define MAX 1000
int main(void)
{
int wordcount = 0, charcount = 0;
FILE *fptr, *fptr1;
int i, len, index, isUnique;
char words[MAX][50];
char temp[50];
int t;
char word[50];
int count[MAX];
fptr = fopen("file.txt", "r");
if (fptr == NULL)
{
printf("Unable to open file. ");
exit(1);
}
for (i = 0; i<MAX; i++)
count[i] = 0;
index = 0;
while (fscanf(fptr, "%s", word) != EOF)
{
len = strlen(word);
if (ispunct(word[len - 1]))
word[len - 1] = '';
for (int i = 0; i<len; i++)
{
if (word[i] >= 'A'&&word[i] <= 'Z')
{
word[i] = word[i] + 32;
}
}
isUnique = 1;
for (i = 0; i<index && isUnique; i++)
{
if (strcmp(words[i], word) == 0)
isUnique = 0;
}
if (isUnique)
{
strcpy(words[index], word);
count[index]++;
index++;
}
else
{
count[i - 1]++;
}
}
fclose(fptr);
fptr1 = fopen("out.txt", "w");
if (fptr1 == NULL)
{
printf("Unable to open file. ");
exit(1);
}
for (i = 0; i < index - 1; i++)
{
for (int j = i + 1; j < index; j++)
{
if (strcmp(words[i], words[j]) > 0)
{
strcpy(temp, words[i]);
strcpy(words[i], words[j]);
strcpy(words[j], temp);
t = count[i];
count[i] = count[j];
count[j] = t;
}
}
}
wordcount = index;
for (int i = 0; i<index; i++)
{
charcount = charcount + strlen(words[i]);
}
printf("Total words=%d", wordcount);
printf(" Total character=%d", charcount);
for (i = 0; i<index; i++)
{
fprintf(fptr1, "%-15s => %d ", words[i], count[i]);
}
return 0;
}
1
To add more of your C code to the program, you can use #include statement. This is one of the most common ways to add code to run in your program.
Whatever answers related to "#include "
#include include d3 [2, 6, 13, 99, 27].any? { |i| [6, 13].include? i } stackoverflow c select include include for sprintf include vs extend latex hyperlinks subfigure latex How to Insert a Picture into LaTeX Href not working latex overleaf latex chapter no new page what should bug report include bug report include insert figure latex insert figure latex include with where clause in sequelize latex figure latex figure mongodb filter include all other fields xmls:android to include in xml include path of angular js and bootstrap include antoher file wagger #include main () { int a; printf("Enter the number:"); scanf("%d",&a); printf("the number was:",a); return 0; } import vs include command in ansible js jquery include external script does std::map include multiple apearances? #include int main() { char array [100]; scanf("%s", array); printf("%s",array); return 0; } how to include header tenant and data in curl post request how to set include package parameter in error prone command line submit form include input type submit
View All Whatever queries
Whatever queries related to "#include "
include with where clause in sequelize #include int main(){ int i,j; i=j=2,3; while(--i&&j++) printf(%d %d,i,j); return 0; } #include js jquery include external script include d3 include vs extend url(r'^articles/', include('articles.urls')), NameError: name 'url' is not defined xmls:android to include in xml submit form include input type submit mongodb filter include all other fields include for sprintf c select include what should bug report include bug report include include path of angular js and bootstrap [2, 6, 13, 99, 27].any? { |i| [6, 13].include? i } stackoverflow #include int main() { char array [100]; scanf("%s", array); printf("%s",array); return 0; } include antoher file wagger import vs include command in ansible necessarAndroid SDK does not include your Target SDK of 28. #include main () { int a; printf("Enter the number:"); scanf("%d",&a); printf("the number was:",a); return 0; } does std::map include multiple apearances? how to set include package parameter in error prone command line how to include header tenant and data in curl post request
Browse Other Code Languages
Abap ActionScript Assembly BASIC C C# C++ Clojure Cobol CSS Dart Delphi Elixir Erlang F# Fortran Go Groovy Haskell Html Java Javascript Julia Kotlin Lisp Lua Matlab Objective-C Pascal Perl PHP PostScript Prolog Python R Ruby Rust Scala Scheme Shell/Bash Smalltalk SQL Swift TypeScript VBA WebAssembly Whatever