|
-
May 31st, 2002, 05:52 PM
#1
Thread Starter
Fanatic Member
files
heres what i want to do
read in a file, read in each line, if the line contains something, then modfy that line, save the text file
the thing i dont get it that i have to specify a length to read in, i dont know the length for each line, help?
thanks
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
May 31st, 2002, 09:09 PM
#2
Thread Starter
Fanatic Member
i get errors
c:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\C++\php_format\php_format.cpp(52): error C2784: 'std::basic_istream<_Elem,_Traits> &std::getline(std::basic_istream<_Elem,_Traits> &,std::basic_string<_Elem,_Traits,_Alloc> &)' : could not deduce template argument for 'std::basic_istream<_Elem,_Traits> &' from 'ifstream'
c:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\C++\php_format\php_format.cpp(44): error C2872: 'ifstream' : ambiguous symbol
bah?
PHP Code:
ifstream ifile;
ifile.open(argv[1]);
if(!ifile){
printf("Could not open file, or file does not exist!\n");
return exit();
}
while(getline(ifile, sTmp))
{
//validate stuff in here
printf("%s\n", sTmp.c_str());
printf("%c",istag(sTmp.c_str());
//sFile += sTmp + '\n';
}
istag() is a seperate function i wrote
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
May 31st, 2002, 09:16 PM
#3
Thread Starter
Fanatic Member
hmm
when i do
while(getline(ifile, sTmp))
it says "2 arguments specified, 3 needed"
while(getline(ifile, sTmp, '\n'))
it says "3 arguments specified, 2 needed"
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
May 31st, 2002, 09:19 PM
#4
Thread Starter
Fanatic Member
ok fixed the other errors
what does "error C2872: 'ifstream' : ambiguous symbol
" mean?
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Jun 1st, 2002, 03:18 AM
#5
Monday Morning Lunatic
Did you include <fstream> ?
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 1st, 2002, 09:46 AM
#6
Thread Starter
Fanatic Member
yup.
im using vc7 if that helps
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Jun 1st, 2002, 10:16 AM
#7
Frenzied Member
if you have #include <fstream> you'll need
using namespace std;
otherwise you'll have to use fstream.h
I've always used .h, works for me
don't know how much help this is but,
-
Jun 1st, 2002, 10:17 AM
#8
Thread Starter
Fanatic Member
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Jun 1st, 2002, 10:18 AM
#9
Frenzied Member
can you post the whole source if its not that long? so I can put it in VC++ and try to get it
-
Jun 1st, 2002, 10:23 AM
#10
Thread Starter
Fanatic Member
PHP Code:
ifstream ifile; //file stream var
ifile.open(argv[1]);
if(!ifile){
printf("Could not open file, or file does not exist!\n");
return exit();
}
sFile="";
while(ifile.getline(input,255,'\n') && !ifile.eof()) {
debug(input); //DEBUG
if(istag(input)=='h'){ //its an HTML tag
sTmp = "<?";
strreplace(input,"\"","\\\""); //replace " and ' with \" and \'
sTmp += input;
sTmp += "?>";
}
sFile+=sTmp + '\n';
}
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Jun 1st, 2002, 10:43 AM
#11
Frenzied Member
the problem is on this line
strreplace(input,""","\\""); //replace " and ' with \" and '
you can't say " " ", it thinks the second one is ending the string. To make it ignore any character, put \ in front of it, so """ can now be "\"", this will make a quote in the string
-
Jun 1st, 2002, 10:49 AM
#12
Thread Starter
Fanatic Member
the php formatting thing took it out. i have the backslash there though.
it says the error is in ifstream ifile.
heres that whole if:
if(istag(input)=='h'){ //its an HTML tag
sTmp = "<? echo \"";
strreplace(input,"\"","\\\""); //replace " and ' with \" and \'
sTmp += input;
sTmp += "\" ?>";
}
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Jun 1st, 2002, 10:51 AM
#13
Monday Morning Lunatic
Originally posted by SteveCRM
if you have #include <fstream> you'll need
using namespace std;
otherwise you'll have to use fstream.h
I've always used .h, works for me
don't know how much help this is but,
Should always use <fstream>, .h won't work at all very soon (just try using it with VC7, it complains bitterly
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 1st, 2002, 10:55 AM
#14
Frenzied Member
noooooooooooooo hehe gotta start using that
oh maybe this then?
you need to set what file
ifstream ifile(yourfile, opentype);
most popular open types are ios::trunc, ios::app (truncate, and append)
-
Jun 1st, 2002, 10:58 AM
#15
Thread Starter
Fanatic Member
alright, i did clean buld, and rebuilt it, now it doesnt complain about that
now its
c:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\C++\php_format\php_format.cpp(68): error C2001: newline in constant
c:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\C++\php_format\php_format.cpp(68): error C2015: too many characters in constant
c:\Documents and Settings\Administrator\My Documents\Visual Studio Projects\C++\php_format\php_format.cpp(68): error C2146: syntax error : missing ')' before identifier 'and'
Visit www.fragblast.com
Gaming, forums, and a online RPG/Battle system
(__Flagg) DOT NET? is this a Hindi Dating service?
-
Jun 2nd, 2002, 04:40 AM
#16
Monday Morning Lunatic
You've got some mismatched quotes/backslashes somewhere, I think.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|