L
lumo2000
hello NG,
i am trying to do some syscalls and therefore i need to put some text
together.
its no problem as long i want to cout the text to display, but when i
want to use it
as parameter for functions the variable only passes NULL....
the out commented code segments is my try to convert the static char*
to char* so i can work with this one, but it does not work either...
(compiles but app crashes then...)
i load the names from the list to memory, and i
my code
#include "stdafx.h"
//#include "fstream.h"
bool listexists();
void getPopularNames();
int _tmain(int argc, _TCHAR* argv[])
{
if (listexists())
printf("taxa list file found!\n");
else
printf("error 404 - file [%S] not found\n");
getPopularNames();
// to get popular name call php file with latin name as
parameter
// php.exe getPopularName.php "latin name"
return 0;
}
void getPopularNames()
{
ifstream filestr;
std::string name;
//char* name;
std::string res;
filestr.open("taxa.liste",ios::in);
int counter = 0;
cout << "processing";
if( filestr.is_open() )
{
while( getline(filestr, name) ) {
char call[1024];
cout << name << '\n';
//char *nonconstant_namecopy;
//nonconstant_namecopy = new
char[name.length() + 1];
//strcpy_s(nonconstant_namecopy, name.length()
+1, name.c_str());
sprintf_s(call, "php.exe getPopularName.php
\"%S\"", name);
//cout << "<" << nonconstant_namecopy << ">";
//strcpy(call, name.c_str );
cout << "[call]" << call << "[/call]\n";
system(call);
// clean up
// delete [] nonconstant_namecopy;
cout << ".";
counter++;
}
}
cout << "finished processing " << counter << " latin names.";
filestr.close();
}
// checking if the list exists or not
bool listexists()
{
bool flag = false;
fstream filestr;
filestr.open("taxa.liste",ios::in);
if( filestr.is_open() )
{
flag=true;
}
filestr.close();
return flag;
}
i am trying to do some syscalls and therefore i need to put some text
together.
its no problem as long i want to cout the text to display, but when i
want to use it
as parameter for functions the variable only passes NULL....
the out commented code segments is my try to convert the static char*
to char* so i can work with this one, but it does not work either...
(compiles but app crashes then...)
i load the names from the list to memory, and i
my code
#include "stdafx.h"
//#include "fstream.h"
bool listexists();
void getPopularNames();
int _tmain(int argc, _TCHAR* argv[])
{
if (listexists())
printf("taxa list file found!\n");
else
printf("error 404 - file [%S] not found\n");
getPopularNames();
// to get popular name call php file with latin name as
parameter
// php.exe getPopularName.php "latin name"
return 0;
}
void getPopularNames()
{
ifstream filestr;
std::string name;
//char* name;
std::string res;
filestr.open("taxa.liste",ios::in);
int counter = 0;
cout << "processing";
if( filestr.is_open() )
{
while( getline(filestr, name) ) {
char call[1024];
cout << name << '\n';
//char *nonconstant_namecopy;
//nonconstant_namecopy = new
char[name.length() + 1];
//strcpy_s(nonconstant_namecopy, name.length()
+1, name.c_str());
sprintf_s(call, "php.exe getPopularName.php
\"%S\"", name);
//cout << "<" << nonconstant_namecopy << ">";
//strcpy(call, name.c_str );
cout << "[call]" << call << "[/call]\n";
system(call);
// clean up
// delete [] nonconstant_namecopy;
cout << ".";
counter++;
}
}
cout << "finished processing " << counter << " latin names.";
filestr.close();
}
// checking if the list exists or not
bool listexists()
{
bool flag = false;
fstream filestr;
filestr.open("taxa.liste",ios::in);
if( filestr.is_open() )
{
flag=true;
}
filestr.close();
return flag;
}