finish lab23
This commit is contained in:
parent
ecd7646390
commit
d095f43a51
42
lab23/files/out1.txt
Normal file
42
lab23/files/out1.txt
Normal file
@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
#define BUF_LEN 128
|
||||
|
||||
void task1() {
|
||||
%puts("===== task1 =====");
|
||||
|
||||
%char infilepath[] = "files/text1.txt";
|
||||
%FILE* fin = fopen(infilepath, "r");
|
||||
%if (fin == NULL) {
|
||||
%%printf("Cannot open file %s\n", infilepath);
|
||||
%%return;
|
||||
%}
|
||||
|
||||
%char outfilepath[] = "files/out1.txt";
|
||||
%FILE* fout = fopen(outfilepath, "w");
|
||||
%if (fin == NULL) {
|
||||
%%printf("Cannot open file %s\n", outfilepath);
|
||||
%%return;
|
||||
%}
|
||||
|
||||
%char buf[BUF_LEN];
|
||||
%while (fgets(buf, BUF_LEN, fin) != NULL) {
|
||||
%%for (int i = 0; buf[i] != '\0'; i++) {
|
||||
%%%if (buf[i] == '\t') {
|
||||
%%%%buf[i] = '%';
|
||||
%%%}
|
||||
%%}
|
||||
%%fprintf(fout, "%s", buf);
|
||||
%%printf(">>%s<<", buf);
|
||||
%}
|
||||
%fclose(fin);
|
||||
%fclose(fout);
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
%task1();
|
||||
|
||||
|
||||
|
||||
%return 0;
|
||||
}
|
402
lab23/files/out2.txt
Normal file
402
lab23/files/out2.txt
Normal file
@ -0,0 +1,402 @@
|
||||
# ---> VISUALSTUDIO
|
||||
## IGNORE VISUAL STUDIO TEMPORARY FILES, BUILD RESULTS, AND
|
||||
## FILES GENERATED BY POPULAR VISUAL STUDIO ADD-ONS.
|
||||
##
|
||||
## GET LATEST FROM HTTPS://GITHUB.COM/GITHUB/GITIGNORE/BLOB/MAIN/VISUALSTUDIO.GITIGNORE
|
||||
|
||||
# MY FILTER
|
||||
|
||||
# USER-SPECIFIC FILES
|
||||
*.RSUSER
|
||||
*.SUO
|
||||
*.USER
|
||||
*.USEROSSCACHE
|
||||
*.SLN.DOCSTATES
|
||||
|
||||
# USER-SPECIFIC FILES (MONODEVELOP/XAMARIN STUDIO)
|
||||
*.USERPREFS
|
||||
|
||||
# MONO AUTO GENERATED FILES
|
||||
MONO_CRASH.*
|
||||
|
||||
# BUILD RESULTS
|
||||
[DD]EBUG/
|
||||
[DD]EBUGPUBLIC/
|
||||
[RR]ELEASE/
|
||||
[RR]ELEASES/
|
||||
X64/
|
||||
X86/
|
||||
[WW][II][NN]32/
|
||||
[AA][RR][MM]/
|
||||
[AA][RR][MM]64/
|
||||
BLD/
|
||||
[BB]IN/
|
||||
[OO]BJ/
|
||||
[LL]OG/
|
||||
[LL]OGS/
|
||||
|
||||
# VISUAL STUDIO 2015/2017 CACHE/OPTIONS DIRECTORY
|
||||
.VS/
|
||||
# UNCOMMENT IF YOU HAVE TASKS THAT CREATE THE PROJECT'S STATIC FILES IN WWWROOT
|
||||
#WWWROOT/
|
||||
|
||||
# VISUAL STUDIO 2017 AUTO GENERATED FILES
|
||||
GENERATED\ FILES/
|
||||
|
||||
# MSTEST TEST RESULTS
|
||||
[TT]EST[RR]ESULT*/
|
||||
[BB]UILD[LL]OG.*
|
||||
|
||||
# NUNIT
|
||||
*.VISUALSTATE.XML
|
||||
TESTRESULT.XML
|
||||
NUNIT-*.XML
|
||||
|
||||
# BUILD RESULTS OF AN ATL PROJECT
|
||||
[DD]EBUGPS/
|
||||
[RR]ELEASEPS/
|
||||
DLLDATA.C
|
||||
|
||||
# BENCHMARK RESULTS
|
||||
BENCHMARKDOTNET.ARTIFACTS/
|
||||
|
||||
# .NET CORE
|
||||
PROJECT.LOCK.JSON
|
||||
PROJECT.FRAGMENT.LOCK.JSON
|
||||
ARTIFACTS/
|
||||
|
||||
# ASP.NET SCAFFOLDING
|
||||
SCAFFOLDINGREADME.TXT
|
||||
|
||||
# STYLECOP
|
||||
STYLECOPREPORT.XML
|
||||
|
||||
# FILES BUILT BY VISUAL STUDIO
|
||||
*_I.C
|
||||
*_P.C
|
||||
*_H.H
|
||||
*.ILK
|
||||
*.META
|
||||
*.OBJ
|
||||
*.IOBJ
|
||||
*.PCH
|
||||
*.PDB
|
||||
*.IPDB
|
||||
*.PGC
|
||||
*.PGD
|
||||
*.RSP
|
||||
*.SBR
|
||||
*.TLB
|
||||
*.TLI
|
||||
*.TLH
|
||||
*.TMP
|
||||
*.TMP_PROJ
|
||||
*_WPFTMP.CSPROJ
|
||||
*.LOG
|
||||
*.TLOG
|
||||
*.VSPSCC
|
||||
*.VSSSCC
|
||||
.BUILDS
|
||||
*.PIDB
|
||||
*.SVCLOG
|
||||
*.SCC
|
||||
|
||||
# CHUTZPAH TEST FILES
|
||||
_CHUTZPAH*
|
||||
|
||||
# VISUAL C++ CACHE FILES
|
||||
IPCH/
|
||||
*.APS
|
||||
*.NCB
|
||||
*.OPENDB
|
||||
*.OPENSDF
|
||||
*.SDF
|
||||
*.CACHEFILE
|
||||
*.VC.DB
|
||||
*.VC.VC.OPENDB
|
||||
|
||||
# VISUAL STUDIO PROFILER
|
||||
*.PSESS
|
||||
*.VSP
|
||||
*.VSPX
|
||||
*.SAP
|
||||
|
||||
# VISUAL STUDIO TRACE FILES
|
||||
*.E2E
|
||||
|
||||
# TFS 2012 LOCAL WORKSPACE
|
||||
$TF/
|
||||
|
||||
# GUIDANCE AUTOMATION TOOLKIT
|
||||
*.GPSTATE
|
||||
|
||||
# RESHARPER IS A .NET CODING ADD-IN
|
||||
_RESHARPER*/
|
||||
*.[RR]E[SS]HARPER
|
||||
*.DOTSETTINGS.USER
|
||||
|
||||
# TEAMCITY IS A BUILD ADD-IN
|
||||
_TEAMCITY*
|
||||
|
||||
# DOTCOVER IS A CODE COVERAGE TOOL
|
||||
*.DOTCOVER
|
||||
|
||||
# AXOCOVER IS A CODE COVERAGE TOOL
|
||||
.AXOCOVER/*
|
||||
!.AXOCOVER/SETTINGS.JSON
|
||||
|
||||
# COVERLET IS A FREE, CROSS PLATFORM CODE COVERAGE TOOL
|
||||
COVERAGE*.JSON
|
||||
COVERAGE*.XML
|
||||
COVERAGE*.INFO
|
||||
|
||||
# VISUAL STUDIO CODE COVERAGE RESULTS
|
||||
*.COVERAGE
|
||||
*.COVERAGEXML
|
||||
|
||||
# NCRUNCH
|
||||
_NCRUNCH_*
|
||||
.*CRUNCH*.LOCAL.XML
|
||||
NCRUNCHTEMP_*
|
||||
|
||||
# MIGHTYMOOSE
|
||||
*.MM.*
|
||||
AUTOTEST.NET/
|
||||
|
||||
# WEB WORKBENCH (SASS)
|
||||
.SASS-CACHE/
|
||||
|
||||
# INSTALLSHIELD OUTPUT FOLDER
|
||||
[EE]XPRESS/
|
||||
|
||||
# DOCPROJECT IS A DOCUMENTATION GENERATOR ADD-IN
|
||||
DOCPROJECT/BUILDHELP/
|
||||
DOCPROJECT/HELP/*.HXT
|
||||
DOCPROJECT/HELP/*.HXC
|
||||
DOCPROJECT/HELP/*.HHC
|
||||
DOCPROJECT/HELP/*.HHK
|
||||
DOCPROJECT/HELP/*.HHP
|
||||
DOCPROJECT/HELP/HTML2
|
||||
DOCPROJECT/HELP/HTML
|
||||
|
||||
# CLICK-ONCE DIRECTORY
|
||||
PUBLISH/
|
||||
|
||||
# PUBLISH WEB OUTPUT
|
||||
*.[PP]UBLISH.XML
|
||||
*.AZUREPUBXML
|
||||
# NOTE: COMMENT THE NEXT LINE IF YOU WANT TO CHECKIN YOUR WEB DEPLOY SETTINGS,
|
||||
# BUT DATABASE CONNECTION STRINGS (WITH POTENTIAL PASSWORDS) WILL BE UNENCRYPTED
|
||||
*.PUBXML
|
||||
*.PUBLISHPROJ
|
||||
|
||||
# MICROSOFT AZURE WEB APP PUBLISH SETTINGS. COMMENT THE NEXT LINE IF YOU WANT TO
|
||||
# CHECKIN YOUR AZURE WEB APP PUBLISH SETTINGS, BUT SENSITIVE INFORMATION CONTAINED
|
||||
# IN THESE SCRIPTS WILL BE UNENCRYPTED
|
||||
PUBLISHSCRIPTS/
|
||||
|
||||
# NUGET PACKAGES
|
||||
*.NUPKG
|
||||
# NUGET SYMBOL PACKAGES
|
||||
*.SNUPKG
|
||||
# THE PACKAGES FOLDER CAN BE IGNORED BECAUSE OF PACKAGE RESTORE
|
||||
**/[PP]ACKAGES/*
|
||||
# EXCEPT BUILD/, WHICH IS USED AS AN MSBUILD TARGET.
|
||||
!**/[PP]ACKAGES/BUILD/
|
||||
# UNCOMMENT IF NECESSARY HOWEVER GENERALLY IT WILL BE REGENERATED WHEN NEEDED
|
||||
#!**/[PP]ACKAGES/REPOSITORIES.CONFIG
|
||||
# NUGET V3'S PROJECT.JSON FILES PRODUCES MORE IGNORABLE FILES
|
||||
*.NUGET.PROPS
|
||||
*.NUGET.TARGETS
|
||||
|
||||
# MICROSOFT AZURE BUILD OUTPUT
|
||||
CSX/
|
||||
*.BUILD.CSDEF
|
||||
|
||||
# MICROSOFT AZURE EMULATOR
|
||||
ECF/
|
||||
RCF/
|
||||
|
||||
# WINDOWS STORE APP PACKAGE DIRECTORIES AND FILES
|
||||
APPPACKAGES/
|
||||
BUNDLEARTIFACTS/
|
||||
PACKAGE.STOREASSOCIATION.XML
|
||||
_PKGINFO.TXT
|
||||
*.APPX
|
||||
*.APPXBUNDLE
|
||||
*.APPXUPLOAD
|
||||
|
||||
# VISUAL STUDIO CACHE FILES
|
||||
# FILES ENDING IN .CACHE CAN BE IGNORED
|
||||
*.[CC]ACHE
|
||||
# BUT KEEP TRACK OF DIRECTORIES ENDING IN .CACHE
|
||||
!?*.[CC]ACHE/
|
||||
|
||||
# OTHERS
|
||||
CLIENTBIN/
|
||||
~$*
|
||||
*~
|
||||
*.DBMDL
|
||||
*.DBPROJ.SCHEMAVIEW
|
||||
*.JFM
|
||||
*.PFX
|
||||
*.PUBLISHSETTINGS
|
||||
ORLEANS.CODEGEN.CS
|
||||
|
||||
# INCLUDING STRONG NAME FILES CAN PRESENT A SECURITY RISK
|
||||
# (HTTPS://GITHUB.COM/GITHUB/GITIGNORE/PULL/2483#ISSUE-259490424)
|
||||
#*.SNK
|
||||
|
||||
# SINCE THERE ARE MULTIPLE WORKFLOWS, UNCOMMENT NEXT LINE TO IGNORE BOWER_COMPONENTS
|
||||
# (HTTPS://GITHUB.COM/GITHUB/GITIGNORE/PULL/1529#ISSUECOMMENT-104372622)
|
||||
#BOWER_COMPONENTS/
|
||||
|
||||
# RIA/SILVERLIGHT PROJECTS
|
||||
GENERATED_CODE/
|
||||
|
||||
# BACKUP & REPORT FILES FROM CONVERTING AN OLD PROJECT FILE
|
||||
# TO A NEWER VISUAL STUDIO VERSION. BACKUP FILES ARE NOT NEEDED,
|
||||
# BECAUSE WE HAVE GIT ;-)
|
||||
_UPGRADEREPORT_FILES/
|
||||
BACKUP*/
|
||||
UPGRADELOG*.XML
|
||||
UPGRADELOG*.HTM
|
||||
SERVICEFABRICBACKUP/
|
||||
*.RPTPROJ.BAK
|
||||
|
||||
# SQL SERVER FILES
|
||||
*.MDF
|
||||
*.LDF
|
||||
*.NDF
|
||||
|
||||
# BUSINESS INTELLIGENCE PROJECTS
|
||||
*.RDL.DATA
|
||||
*.BIM.LAYOUT
|
||||
*.BIM_*.SETTINGS
|
||||
*.RPTPROJ.RSUSER
|
||||
*- [BB]ACKUP.RDL
|
||||
*- [BB]ACKUP ([0-9]).RDL
|
||||
*- [BB]ACKUP ([0-9][0-9]).RDL
|
||||
|
||||
# MICROSOFT FAKES
|
||||
FAKESASSEMBLIES/
|
||||
|
||||
# GHOSTDOC PLUGIN SETTING FILE
|
||||
*.GHOSTDOC.XML
|
||||
|
||||
# NODE.JS TOOLS FOR VISUAL STUDIO
|
||||
.NTVS_ANALYSIS.DAT
|
||||
NODE_MODULES/
|
||||
|
||||
# VISUAL STUDIO 6 BUILD LOG
|
||||
*.PLG
|
||||
|
||||
# VISUAL STUDIO 6 WORKSPACE OPTIONS FILE
|
||||
*.OPT
|
||||
|
||||
# VISUAL STUDIO 6 AUTO-GENERATED WORKSPACE FILE (CONTAINS WHICH FILES WERE OPEN ETC.)
|
||||
*.VBW
|
||||
|
||||
# VISUAL STUDIO 6 AUTO-GENERATED PROJECT FILE (CONTAINS WHICH FILES WERE OPEN ETC.)
|
||||
*.VBP
|
||||
|
||||
# VISUAL STUDIO 6 WORKSPACE AND PROJECT FILE (WORKING PROJECT FILES CONTAINING FILES TO INCLUDE IN PROJECT)
|
||||
*.DSW
|
||||
*.DSP
|
||||
|
||||
# VISUAL STUDIO 6 TECHNICAL FILES
|
||||
*.NCB
|
||||
*.APS
|
||||
|
||||
# VISUAL STUDIO LIGHTSWITCH BUILD OUTPUT
|
||||
**/*.HTMLCLIENT/GENERATEDARTIFACTS
|
||||
**/*.DESKTOPCLIENT/GENERATEDARTIFACTS
|
||||
**/*.DESKTOPCLIENT/MODELMANIFEST.XML
|
||||
**/*.SERVER/GENERATEDARTIFACTS
|
||||
**/*.SERVER/MODELMANIFEST.XML
|
||||
_PVT_EXTENSIONS
|
||||
|
||||
# PAKET DEPENDENCY MANAGER
|
||||
.PAKET/PAKET.EXE
|
||||
PAKET-FILES/
|
||||
|
||||
# FAKE - F# MAKE
|
||||
.FAKE/
|
||||
|
||||
# CODERUSH PERSONAL SETTINGS
|
||||
.CR/PERSONAL
|
||||
|
||||
# PYTHON TOOLS FOR VISUAL STUDIO (PTVS)
|
||||
__PYCACHE__/
|
||||
*.PYC
|
||||
|
||||
# CAKE - UNCOMMENT IF YOU ARE USING IT
|
||||
# TOOLS/**
|
||||
# !TOOLS/PACKAGES.CONFIG
|
||||
|
||||
# TABS STUDIO
|
||||
*.TSS
|
||||
|
||||
# TELERIK'S JUSTMOCK CONFIGURATION FILE
|
||||
*.JMCONFIG
|
||||
|
||||
# BIZTALK BUILD OUTPUT
|
||||
*.BTP.CS
|
||||
*.BTM.CS
|
||||
*.ODX.CS
|
||||
*.XSD.CS
|
||||
|
||||
# OPENCOVER UI ANALYSIS RESULTS
|
||||
OPENCOVER/
|
||||
|
||||
# AZURE STREAM ANALYTICS LOCAL RUN OUTPUT
|
||||
ASALOCALRUN/
|
||||
|
||||
# MSBUILD BINARY AND STRUCTURED LOG
|
||||
*.BINLOG
|
||||
|
||||
# NVIDIA NSIGHT GPU DEBUGGER CONFIGURATION FILE
|
||||
*.NVUSER
|
||||
|
||||
# MFRACTORS (XAMARIN PRODUCTIVITY TOOL) WORKING FOLDER
|
||||
.MFRACTOR/
|
||||
|
||||
# LOCAL HISTORY FOR VISUAL STUDIO
|
||||
.LOCALHISTORY/
|
||||
|
||||
# VISUAL STUDIO HISTORY (VSHISTORY) FILES
|
||||
.VSHISTORY/
|
||||
|
||||
# BEATPULSE HEALTHCHECK TEMP DATABASE
|
||||
HEALTHCHECKSDB
|
||||
|
||||
# BACKUP FOLDER FOR PACKAGE REFERENCE CONVERT TOOL IN VISUAL STUDIO 2017
|
||||
MIGRATIONBACKUP/
|
||||
|
||||
# IONIDE (CROSS PLATFORM F# VS CODE TOOLS) WORKING FOLDER
|
||||
.IONIDE/
|
||||
|
||||
# FODY - AUTO-GENERATED XML SCHEMA
|
||||
FODYWEAVERS.XSD
|
||||
|
||||
# VS CODE FILES FOR THOSE WORKING ON MULTIPLE TOOLS
|
||||
.VSCODE/*
|
||||
!.VSCODE/SETTINGS.JSON
|
||||
!.VSCODE/TASKS.JSON
|
||||
!.VSCODE/LAUNCH.JSON
|
||||
!.VSCODE/EXTENSIONS.JSON
|
||||
*.CODE-WORKSPACE
|
||||
|
||||
# LOCAL HISTORY FOR VISUAL STUDIO CODE
|
||||
.HISTORY/
|
||||
|
||||
# WINDOWS INSTALLER FILES FROM BUILD OUTPUTS
|
||||
*.CAB
|
||||
*.MSI
|
||||
*.MSIX
|
||||
*.MSM
|
||||
*.MSP
|
||||
|
||||
# JETBRAINS RIDER
|
||||
*.SLN.IML
|
||||
|
42
lab23/files/out3.txt
Normal file
42
lab23/files/out3.txt
Normal file
@ -0,0 +1,42 @@
|
||||
##include <stdio.h>
|
||||
##define BUF_LEN 128
|
||||
|
||||
#void task1() {
|
||||
# puts("===== task1 =====");
|
||||
|
||||
# char infilepath[] = "files/text1.txt";
|
||||
# FILE* fin = fopen(infilepath, "r");
|
||||
# if (fin == NULL) {
|
||||
# printf("Cannot open file %s\n", infilepath);
|
||||
# return;
|
||||
}
|
||||
|
||||
# char outfilepath[] = "files/out1.txt";
|
||||
# FILE* fout = fopen(outfilepath, "w");
|
||||
# if (fin == NULL) {
|
||||
# printf("Cannot open file %s\n", outfilepath);
|
||||
# return;
|
||||
}
|
||||
|
||||
# char buf[BUF_LEN];
|
||||
# while (fgets(buf, BUF_LEN, fin) != NULL) {
|
||||
# for (int i = 0; buf[i] != '\0'; i++) {
|
||||
# if (buf[i] == '\t') {
|
||||
# buf[i] = '%';
|
||||
}
|
||||
}
|
||||
# fprintf(fout, "%s", buf);
|
||||
# printf(">>%s<<", buf);
|
||||
}
|
||||
# fclose(fin);
|
||||
# fclose(fout);
|
||||
}
|
||||
|
||||
#int main() {
|
||||
|
||||
# task1();
|
||||
|
||||
|
||||
|
||||
# return 0;
|
||||
}
|
42
lab23/files/out4.txt
Normal file
42
lab23/files/out4.txt
Normal file
@ -0,0 +1,42 @@
|
||||
_include _stdio_h_
|
||||
_define BUF_LEN 128
|
||||
|
||||
void task1__ _
|
||||
puts_______ task1 ________
|
||||
|
||||
char infilepath__ _ _files_text1_txt__
|
||||
FILE_ fin _ fopen_infilepath_ _r___
|
||||
if _fin __ NULL_ _
|
||||
printf__Cannot open file _s_n__ infilepath__
|
||||
return_
|
||||
_
|
||||
|
||||
char outfilepath__ _ _files_out1_txt__
|
||||
FILE_ fout _ fopen_outfilepath_ _w___
|
||||
if _fin __ NULL_ _
|
||||
printf__Cannot open file _s_n__ outfilepath__
|
||||
return_
|
||||
_
|
||||
|
||||
char buf_BUF_LEN__
|
||||
while _fgets_buf_ BUF_LEN_ fin_ __ NULL_ _
|
||||
for _int i _ 0_ buf_i_ __ __0__ i___ _
|
||||
if _buf_i_ __ __t__ _
|
||||
buf_i_ _ ____
|
||||
_
|
||||
_
|
||||
fprintf_fout_ __s__ buf__
|
||||
printf_____s____ buf__
|
||||
_
|
||||
fclose_fin__
|
||||
fclose_fout__
|
||||
_
|
||||
|
||||
int main__ _
|
||||
|
||||
task1___
|
||||
|
||||
|
||||
|
||||
return 0_
|
||||
_
|
42
lab23/files/out5.txt
Normal file
42
lab23/files/out5.txt
Normal file
@ -0,0 +1,42 @@
|
||||
0:#include <stdio.h>
|
||||
0:#define BUF_LEN 128
|
||||
0:
|
||||
0:void task1() {
|
||||
1: puts("===== task1 =====");
|
||||
0:
|
||||
1: char infilepath[] = "files/text1.txt";
|
||||
1: FILE* fin = fopen(infilepath, "r");
|
||||
0: if (fin == NULL) {
|
||||
1: printf("Cannot open file %s\n", infilepath);
|
||||
1: return;
|
||||
0: }
|
||||
0:
|
||||
1: char outfilepath[] = "files/out1.txt";
|
||||
1: FILE* fout = fopen(outfilepath, "w");
|
||||
0: if (fin == NULL) {
|
||||
1: printf("Cannot open file %s\n", outfilepath);
|
||||
1: return;
|
||||
0: }
|
||||
0:
|
||||
1: char buf[BUF_LEN];
|
||||
0: while (fgets(buf, BUF_LEN, fin) != NULL) {
|
||||
2: for (int i = 0; buf[i] != '\0'; i++) {
|
||||
0: if (buf[i] == '\t') {
|
||||
1: buf[i] = '%';
|
||||
0: }
|
||||
0: }
|
||||
1: fprintf(fout, "%s", buf);
|
||||
1: printf(">>%s<<", buf);
|
||||
0: }
|
||||
1: fclose(fin);
|
||||
1: fclose(fout);
|
||||
0:}
|
||||
0:
|
||||
0:int main() {
|
||||
0:
|
||||
1: task1();
|
||||
0:
|
||||
0:
|
||||
0:
|
||||
1: return 0;
|
||||
0:}
|
@ -1,7 +1,42 @@
|
||||
wkfkaio gkesgsook pgkdeopgo
|
||||
drgkoigks
|
||||
qbgkopdse edsobhkoidse
|
||||
|
||||
#include <stdio.h>
|
||||
#define BUF_LEN 128
|
||||
|
||||
void task1() {
|
||||
puts("===== task1 =====");
|
||||
|
||||
char infilepath[] = "files/text1.txt";
|
||||
FILE* fin = fopen(infilepath, "r");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", infilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char outfilepath[] = "files/out1.txt";
|
||||
FILE* fout = fopen(outfilepath, "w");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", outfilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[BUF_LEN];
|
||||
while (fgets(buf, BUF_LEN, fin) != NULL) {
|
||||
for (int i = 0; buf[i] != '\0'; i++) {
|
||||
if (buf[i] == '\t') {
|
||||
buf[i] = '%';
|
||||
}
|
||||
}
|
||||
fprintf(fout, "%s", buf);
|
||||
printf(">>%s<<", buf);
|
||||
}
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
task1();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
402
lab23/files/text2.txt
Normal file
402
lab23/files/text2.txt
Normal file
@ -0,0 +1,402 @@
|
||||
# ---> VisualStudio
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
|
||||
|
||||
# my filter
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.tlog
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio 6 auto-generated project file (contains which files were open etc.)
|
||||
*.vbp
|
||||
|
||||
# Visual Studio 6 workspace and project file (working project files containing files to include in project)
|
||||
*.dsw
|
||||
*.dsp
|
||||
|
||||
# Visual Studio 6 technical files
|
||||
*.ncb
|
||||
*.aps
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# Visual Studio History (VSHistory) files
|
||||
.vshistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
||||
# VS Code files for those working on multiple tools
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
*.code-workspace
|
||||
|
||||
# Local History for Visual Studio Code
|
||||
.history/
|
||||
|
||||
# Windows Installer files from build outputs
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# JetBrains Rider
|
||||
*.sln.iml
|
||||
|
42
lab23/files/text3.txt
Normal file
42
lab23/files/text3.txt
Normal file
@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
#define BUF_LEN 128
|
||||
|
||||
void task1() {
|
||||
puts("===== task1 =====");
|
||||
|
||||
char infilepath[] = "files/text1.txt";
|
||||
FILE* fin = fopen(infilepath, "r");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", infilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char outfilepath[] = "files/out1.txt";
|
||||
FILE* fout = fopen(outfilepath, "w");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", outfilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[BUF_LEN];
|
||||
while (fgets(buf, BUF_LEN, fin) != NULL) {
|
||||
for (int i = 0; buf[i] != '\0'; i++) {
|
||||
if (buf[i] == '\t') {
|
||||
buf[i] = '%';
|
||||
}
|
||||
}
|
||||
fprintf(fout, "%s", buf);
|
||||
printf(">>%s<<", buf);
|
||||
}
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
task1();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
42
lab23/files/text4.txt
Normal file
42
lab23/files/text4.txt
Normal file
@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
#define BUF_LEN 128
|
||||
|
||||
void task1() {
|
||||
puts("===== task1 =====");
|
||||
|
||||
char infilepath[] = "files/text1.txt";
|
||||
FILE* fin = fopen(infilepath, "r");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", infilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char outfilepath[] = "files/out1.txt";
|
||||
FILE* fout = fopen(outfilepath, "w");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", outfilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[BUF_LEN];
|
||||
while (fgets(buf, BUF_LEN, fin) != NULL) {
|
||||
for (int i = 0; buf[i] != '\0'; i++) {
|
||||
if (buf[i] == '\t') {
|
||||
buf[i] = '%';
|
||||
}
|
||||
}
|
||||
fprintf(fout, "%s", buf);
|
||||
printf(">>%s<<", buf);
|
||||
}
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
task1();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
42
lab23/files/text5.txt
Normal file
42
lab23/files/text5.txt
Normal file
@ -0,0 +1,42 @@
|
||||
#include <stdio.h>
|
||||
#define BUF_LEN 128
|
||||
|
||||
void task1() {
|
||||
puts("===== task1 =====");
|
||||
|
||||
char infilepath[] = "files/text1.txt";
|
||||
FILE* fin = fopen(infilepath, "r");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", infilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char outfilepath[] = "files/out1.txt";
|
||||
FILE* fout = fopen(outfilepath, "w");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", outfilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[BUF_LEN];
|
||||
while (fgets(buf, BUF_LEN, fin) != NULL) {
|
||||
for (int i = 0; buf[i] != '\0'; i++) {
|
||||
if (buf[i] == '\t') {
|
||||
buf[i] = '%';
|
||||
}
|
||||
}
|
||||
fprintf(fout, "%s", buf);
|
||||
printf(">>%s<<", buf);
|
||||
}
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
task1();
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
@ -129,6 +129,18 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="files\out1.txt" />
|
||||
<Text Include="files\out2.txt" />
|
||||
<Text Include="files\out3.txt" />
|
||||
<Text Include="files\out4.txt" />
|
||||
<Text Include="files\out5.txt" />
|
||||
<Text Include="files\text1.txt" />
|
||||
<Text Include="files\text2.txt" />
|
||||
<Text Include="files\text3.txt" />
|
||||
<Text Include="files\text4.txt" />
|
||||
<Text Include="files\text5.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
|
@ -19,4 +19,36 @@
|
||||
<Filter>Исходные файлы</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Text Include="files\out1.txt">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Text>
|
||||
<Text Include="files\text1.txt">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Text>
|
||||
<Text Include="files\out2.txt">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Text>
|
||||
<Text Include="files\text2.txt">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Text>
|
||||
<Text Include="files\out3.txt">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Text>
|
||||
<Text Include="files\text3.txt">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Text>
|
||||
<Text Include="files\out4.txt">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Text>
|
||||
<Text Include="files\text4.txt">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Text>
|
||||
<Text Include="files\out5.txt">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Text>
|
||||
<Text Include="files\text5.txt">
|
||||
<Filter>Файлы ресурсов</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
</Project>
|
156
lab23/main.c
156
lab23/main.c
@ -1,26 +1,172 @@
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <locale.h>
|
||||
|
||||
#define BUF_LEN 128
|
||||
|
||||
void task1() {
|
||||
char filepath[] = "files/text1.txt";
|
||||
FILE* fin = fopen(filepath, "r");
|
||||
puts("===== task1 =====");
|
||||
|
||||
char infilepath[] = "files/text1.txt";
|
||||
FILE* fin = fopen(infilepath, "r");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", filepath);
|
||||
printf("Cannot open file %s\n", infilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char outfilepath[] = "files/out1.txt";
|
||||
FILE* fout = fopen(outfilepath, "w");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", outfilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[BUF_LEN];
|
||||
while (fgets(buf, BUF_LEN, fin) != NULL) {
|
||||
for (int i = 0; buf[i] != '\0'; i++) {
|
||||
if (buf[i] == '\t') {
|
||||
buf[i] = '%';
|
||||
}
|
||||
}
|
||||
fprintf(fout, "%s", buf);
|
||||
printf(">>%s<<", buf);
|
||||
}
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
void task2() {
|
||||
puts("===== task2 =====");
|
||||
|
||||
char infilepath[] = "files/text2.txt";
|
||||
FILE* fin = fopen(infilepath, "r");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", infilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char outfilepath[] = "files/out2.txt";
|
||||
FILE* fout = fopen(outfilepath, "w");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", outfilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[BUF_LEN];
|
||||
while (fgets(buf, BUF_LEN, fin) != NULL) {
|
||||
for (int i = 0; buf[i] != '\0'; i++) {
|
||||
buf[i] = toupper(buf[i]);
|
||||
}
|
||||
fprintf(fout, "%s", buf);
|
||||
printf(">>%s<<", buf);
|
||||
}
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
void task3() {
|
||||
puts("===== task3 =====");
|
||||
|
||||
char infilepath[] = "files/text3.txt";
|
||||
FILE* fin = fopen(infilepath, "r");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", infilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char outfilepath[] = "files/out3.txt";
|
||||
FILE* fout = fopen(outfilepath, "w");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", outfilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[BUF_LEN];
|
||||
while (fgets(buf, BUF_LEN, fin) != NULL) {
|
||||
for (int i = 0; buf[i] != '\0'; i++) {
|
||||
if (isalpha(buf[i])) {
|
||||
fputc('#', fout);
|
||||
break;
|
||||
}
|
||||
}
|
||||
fprintf(fout, "%s", buf);
|
||||
printf(">>%s<<", buf);
|
||||
}
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
void task4() {
|
||||
puts("===== task4 =====");
|
||||
|
||||
char infilepath[] = "files/text4.txt";
|
||||
FILE* fin = fopen(infilepath, "r");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", infilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char outfilepath[] = "files/out4.txt";
|
||||
FILE* fout = fopen(outfilepath, "w");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", outfilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[BUF_LEN];
|
||||
while (fgets(buf, BUF_LEN, fin) != NULL) {
|
||||
for (int i = 0; buf[i] != '\0'; i++) {
|
||||
if (ispunct(buf[i])) buf[i] = '_';
|
||||
}
|
||||
fprintf(fout, "%s", buf);
|
||||
printf(">>%s<<", buf);
|
||||
}
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
void task5() {
|
||||
puts("===== task5 =====");
|
||||
|
||||
char infilepath[] = "files/text5.txt";
|
||||
FILE* fin = fopen(infilepath, "r");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", infilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char outfilepath[] = "files/out5.txt";
|
||||
FILE* fout = fopen(outfilepath, "w");
|
||||
if (fin == NULL) {
|
||||
printf("Cannot open file %s\n", outfilepath);
|
||||
return;
|
||||
}
|
||||
|
||||
char buf[BUF_LEN];
|
||||
while (fgets(buf, BUF_LEN, fin) != NULL) {
|
||||
int count = 0;
|
||||
for (int i = 0; buf[i] != '\0'; i++) {
|
||||
if (buf[i] == ';') {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
fprintf(fout, "%d:%s", count, buf);
|
||||
printf(">>%d:%s<<", count, buf);
|
||||
}
|
||||
fclose(fin);
|
||||
fclose(fout);
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
|
||||
|
||||
setlocale(LC_CTYPE, "");
|
||||
|
||||
task1();
|
||||
task2();
|
||||
task3();
|
||||
task4();
|
||||
task5();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user