•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 391,588 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,643 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser:
Views: 3391 | Replies: 7
![]() |
•
•
Join Date: Oct 2004
Posts: 31
Reputation:
Rep Power: 4
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?
<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:
Rep Power: 4
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
<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)
#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:
<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:
Rep Power: 4
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:
<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:
<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>![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
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



Linear Mode