juznivetar
Ističe se
- Poruka
- 2.066
Evo source kod mog novog C++ programa za zabiljeske:
Kod:
#include <iostream>
#include <stdlib.h>
#include <string>
#include <io.h>
#include <sys/stat.h>
using namespace std;
int main(){
struct _finddata_t files;
long Files;
FILE *File = NULL;
char r[100];
int fileName = 0;
char fn[65];
char cfile[100];
char full[_MAX_PATH];
string name;
name = _itoa(fileName,fn,10);
string ext= ".txt";
string file = name + ext;
for(int i = 0; i < 100; i++)
cfile[i] = file[i];
cout << cfile;
bool exist = true;
while(exist == true)
{
if((Files = _findfirst(cfile,&files)) == -1L)
exist = false;
else
{
fileName++;
name = _itoa(fileName,fn,10);
string file = name + ext;
for(int i = 0; i < 100; i++)
cfile[i] = file[i];
cout << "\n" << cfile;
}
}
string fp =_fullpath(full,cfile,_MAX_PATH);
cout << "\n\nFile saved:\n" << fp;
cout << "\n\n";
while(EOF != true)
{
File = fopen(cfile,"a+");
cout << "Record text: ";
for(int i = 0;i < 100 || r[i] == '\n';i++)
{
r[i] = getchar();
if(r[i] == '\n')
break;
}
for(int j = 0;j < 100 || r[j] == '\n';j++)
{
putc(r[j],File);
if(r[j] == '\n')
break;
}
fclose(File);
}
return 0;
}