You are here:

C++/Very tricky.

Advertisement


Question
did you check the url i gave you?
it brings different results.

from when you run it on the internet and view the html source.
and run it off your computer.

and this can be a problem if this happens in the html.
i am parsing everyline in [%System%]
and if it adds a new line at the end of every line...
i will bring errors when i later apply those to javascripts.

please help me out...
-------------------------
Followup To
Question -
Hello, this is the worst situation i've been in.
Here it goes.

I am making a web interpreter, and this is a brief version of the code.

#include <iostream.h>
#include <fstream.h>   

int main(){
char ch;
cout << "Content-type: text/html\n\n";
ifstream block("newpass.shenu");
while (!block.eof()){
  ch = block.get();
  if (ch == '\n'){
     //do nothing
  }
  else {
     cout << ch;
  }
}
block.close();
return 0;
}
test.cpp





[%System%]
SnSkinVersion=1
SnSkinVision=2
Thisdoesntwork=3
DONOTQIUT=4
[%End%]

[%Body%]

[%End%]
newpass.shenu


everything compiles fine and works good.
however, there just happens to be one thing that shouldn't of happened.

the result is this http://www.shenu.net/new/error2.cgi
and when you view source.
the following are in separate lines

SnSkinVersion=1
DDDkk=3
fuck=235
dagsdfg=nononoshouldbeoneline!

when i wish them to be
SnSkinVersion=1DDDkk=3fuck=235dagsdfg=nononoshouldbeoneline!
in one line like this.
can you help me otu?
Answer -
Hi there:

  I hope u'll be fine. I think ur code should work as u want it to and it really worked fine for me. I made the same text file and ran ur code. It gave the output that u were expecting. If it is working for me, it should also work fine for u. There's no problem with ur code.

Thanks for contacting me
Zaigham

Answer
Hi there:

  Nice to see u again. The problem is, as u said, u have provided me with a "brief version" of the code, which is not xactly what u r using. I also dont know how r u "running it on internet". What u provided me, simply outputs the contents of a file. So as far as the provided piece of code is concerned, there's no mistake in it and it displays the output as it should be. There might be a mistake with the code u r actually using or in the way u r "running it on the net".

Thanks for contacting me
Zaigham

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


zaigham

Expertise

I can answer any questions that range from the very basics of c++ to the advanced topics like polymorphism, inheritance, composition, multiple inheritance and templates. I can also answer almost every type of questions about c++ data structures like stack, queue, circular queue, linklist(single, double, circular), binary trees, binary search trees, avl trees, 2-3 and 2-3-4 trees. I dont have much experience of mfc and creating guis in visual c++, so plz. dont ask me questions about that.

Experience

I'm working in c++ since the last 6 years. I've good working skills specially in the advanced topics like inheritance, polymorphism and all type of c++ data structures.

©2016 About.com. All rights reserved.