copystr done

This commit is contained in:
Damimani 2026-10-24 14:02:06 +02:00
parent 67a2391619
commit 003a258572
4 changed files with 48 additions and 17 deletions

View file

@ -3,5 +3,5 @@
<Platform Name="x64" />
<Platform Name="x86" />
</Configurations>
<Project Path="feladat3/feladat3.vcxproj" />
<Project Path="feladat3/feladat3.vcxproj" Id="05ad42de-8f96-4351-b07d-784a20d752bd" />
</Solution>

View file

@ -1,12 +1,12 @@
C:\Users\danit\Desktop\cpp\feladat3\feladat3\dataset\testin5.dat
dataset\testin5.dat
C:\nonexistent.dum
C:\Users\danit\Desktop\cpp\feladat3\feladat3\dataset\testin10.dat
dataset\testin10.dat
C:\Users\danit\Desktop\cpp\feladat3\feladat3\dataset\testin50.dat
C:\Users\danit\Desktop\cpp\feladat3\feladat3\dataset\testin100.dat
dataset\testin50.dat
dataset\testin100.dat
C:\Users\danit\Desktop\cpp\feladat3\feladat3\dataset\testin10000.dat
dataset\testin10000.dat

View file

@ -1,9 +1,12 @@
// IFPQYY | Tóth Dániel Mátyás | V1
#include <iostream>
#include <fstream>
#include <filesystem>
#include "feladat3.h"
using namespace std;
static int CopyStr(char* dest, const char* src, const char* concat = "\0");
int GetFilenames(int argc, char* argv[],
char infilenames[MYMAXFILES][MYMAXFN],
char outfilenames[MYMAXFILES][MYMAXFN]) {
@ -29,9 +32,8 @@ int GetFilenames(int argc, char* argv[],
ifstream inputfile(buf);
if (!inputfile.fail())
{
strncpy_s(infilenames[i], buf, strlen(buf)); //if these are not allowed I'm gonna blow up
strncpy_s(outfilenames[i], buf, strlen(buf));
strcat_s(outfilenames[i], ".srt");
CopyStr(infilenames[i], buf);
CopyStr(outfilenames[i], buf, ".srt");
cout << infilenames[i] << " " << outfilenames[i] << "\tOK\n";
i++;
}
@ -42,19 +44,40 @@ int GetFilenames(int argc, char* argv[],
}
argifs.close();
int status = OK;
if (i == 0)
if (readAmount == 0)
{
status = NOK;
cout << "Ures\tNOK\n";
}
while (i < 5) {
infilenames[i][0] = '\0';
outfilenames[i][0] = '\0';
i++;
}
cout << "*DONE\n";
return status;
}
static int CopyStr(char* dest, const char* src, const char* concat) {
if (dest == nullptr || src == nullptr) {
return NOK;
}
int i = 0;
while (src[i] != '\0')
{
dest[i++] = src[i];
}
int j = 0;
while (concat[j] != '\0')
{
dest[i++] = concat[j++];
}
dest[i] = '\0';
return OK;
}
int SortFile(char* infn, char* outfn, unsigned char* buf,
unsigned short* pmin, unsigned short* pmax,
unsigned short* pavg, unsigned short* pn,
unsigned short bufsize = MYBUFSIZE, bool test = false) {
unsigned short bufsize, bool test) {
if (infn == nullptr || outfn == nullptr
|| buf == nullptr || pmin == nullptr
|| pmax == nullptr || pavg == nullptr
@ -62,12 +85,20 @@ int SortFile(char* infn, char* outfn, unsigned char* buf,
{
return NOK;
}
if (bufsize != 8192) //I guess?
if (bufsize != MYBUFSIZE) //I guess?
{
return NOK;
}
}
static int ReadFile(char* filename, int bufsize) {
ifstream argifs(infn, ios_base::binary);
if (!argifs.is_open())
{
return NOK;
}
int size = filesystem::file_size(infn);
cout << size;
short* allVals[MYMAXVALUE];
return OK;
}

View file

@ -12,11 +12,11 @@ int main(int argc, char* argv[]) {
{
return(NOK);
}
/*for (int n = 0; (n < MYMAXFILES) && (infn[n][0] != '\0'); n++)
for (int n = 0; (n < MYMAXFILES) && (infn[n][0] != '\0'); n++)
{
if (SortFile(infn[n], outfn[n], buf, &minv, &maxv, &avgv, &nv) == NOK)
return(NOK);
}*/
}
/*cout << argc;
for (size_t i = 0; i < argc; i++)
{