| | |
EASY question? checking for line feed (return) in a html file with C++
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2004
Posts: 31
Reputation:
Solved Threads: 0
is it just me or am i stupid? (save the comments har har)
im using C++ to pull in a character from a file ... (going character by character)
how do i check for a line feed, or return?
ive checked for currentChar == '\n', =='CRLF', every possibility...
i cant seem to find anything on the web ...
any help would be great...thanks
im using C++ to pull in a character from a file ... (going character by character)
how do i check for a line feed, or return?
C++ Syntax (Toggle Plain Text)
<img src="http://image.jpg" <-- return alt="image" height="100" width="100 />
ive checked for currentChar == '\n', =='CRLF', every possibility...
i cant seem to find anything on the web ...
any help would be great...thanks
•
•
Join Date: Oct 2004
Posts: 31
Reputation:
Solved Threads: 0
no...right now, if there are newlines or whatever, it prints them out .... but i dont want that
but i am skipping any extraneous whitespace
this is the code:
(its not the most effecient, its just a basic program for a web design class to print out the tree structure)
i want it to print it without newlines:
so yea, im trying to get rid of any extraneous whitespace, and check for newlines so i can get rid of it and print on one line
but i am skipping any extraneous whitespace
C++ Syntax (Toggle Plain Text)
<img src= ..../> turns into <img src=..../>
this is the code:
(its not the most effecient, its just a basic program for a web design class to print out the tree structure)
C++ Syntax (Toggle Plain Text)
#include<iostream> using namespace std; int main() { char currentChar, peekChar, prevChar; int tabIndex, tabSize, innerLength, subIndex, numSpaces; int i; tabIndex = 0; tabSize = 4; innerLength = 0; while (!cin.eof()) { currentChar = cin.get(); if (currentChar == '<') { peekChar = cin.peek(); if (peekChar == '!') { tabIndex--; } if (peekChar == '/') { subIndex = 1; } else { tabIndex++; } if (peekChar == '\n') { cout<<"::::::::FOUND AN END OF LINE CHARACTER::::::::::::::::"; } for (i=0; i<(tabIndex*tabSize); i++) { cout<<" "; } while(currentChar != '>') { cout<<currentChar; prevChar = currentChar; currentChar = cin.get(); if (currentChar == ' ') { cout<<currentChar; while (currentChar == ' ') { currentChar = cin.get(); } } } if (prevChar == '/') { subIndex = 1; } if (subIndex == 1) { tabIndex--; subIndex = 2; } cout<<currentChar<<endl; } } return 0; }
i want it to print it without newlines:
C++ Syntax (Toggle Plain Text)
<img src="http....." /> is printed as <img src="http...." />
so yea, im trying to get rid of any extraneous whitespace, and check for newlines so i can get rid of it and print on one line
•
•
Join Date: Oct 2004
Posts: 31
Reputation:
Solved Threads: 0
also, here is part of the output:
as you can see, i just want it to print on one line ...
like this:
C++ Syntax (Toggle Plain Text)
<div class="validate"> <a href="http://validator.w3.org/check?uri=referer"> <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict!" height="31" width="88" /> </a> <a href="http://jigsaw.w3.org/css-validator/check/referer"> <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" /> </a> <br /> <br /> <a href="http://www.whiteazn.com/satworld/contact/feedback.php"> </a> </div> <div class="rowClear"> </div> </div>
as you can see, i just want it to print on one line ...
like this:
C++ Syntax (Toggle Plain Text)
<div class="validate"> <a href="http://validator.w3.org/check?uri=referer"> <img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict!" height="31" width="88" /> </a> <a href="http://jigsaw.w3.org/css-validator/check/referer"> <img src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" height="31" width="88" /> </a> <br /> <br /> <a href="http://www.whiteazn.com/satworld/contact/feedback.php"> </a> </div> <div class="rowClear"> </div> </div>
![]() |
Similar Threads
Other Threads in the C++ Forum
- Previous Thread: Problem with validation in c
- Next Thread: Can Someone Tell me why my program does not run
| Thread Tools | Search this Thread |
api array beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count data database delete desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game getline google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates test text text-file tree unix url vector video visualstudio win32 windows winsock word wordfrequency wxwidgets






