• Forum
  • Lounge
  • lets compile a list of less usual things

 
lets compile a list of less usual things that results in your question not being answered

Pages: 12
while waiting for an answer i realised that it may be sunday night, i may have been excommunicated by the community for being way too big and clever, i may have been asking the questions in a stupid way,i personally am half going with excommunication.

what gets your goat?
#include <conio.h>

#include <iostream.h>

void main

while(!fin.eof())

and other cases where there's far too much wrong with the code to begin answering the actual question.
Last edited on
closed account (iw0XoG1T)
I hate to expose my ignorance but what is wrong with
while(!fin.eof())?
closed account (D80DSL3A)
Seeing others replies ignored by OP.

@devonrevenge:
Re. the thread which I assume has motivated this one, when seeking advice about programming some specific device it is best to start at the manufacturers website, or similar.
A google search on "raspberry pi c++ programming" produces a rich collection of links to the kind of info you are seeking.

In particular (7th item on 1st page of results) is this thread from here on the subject:
http://www.cplusplus.com/forum/lounge/59297/
@chwsks
1
2
3
4
5
while (not at eof)
{
    attempt to read x
    mess with x
}

This is one of the first mistakes people make when attempting a more sophisticated I/O than a simple list of cin >> foo statements.
closed account (1yR4jE8b)
I hate to expose my ignorance but what is wrong with
while(!fin.eof())?


There's errors that can occur before you get to eof.

 
while(fin.good())


Is preferred.
fun2code wrote:

Seeing others replies ignored by OP.



I agree, it is bad when newbies ignore advice given to them. This sort of scenario is irritating (has happened to me a number of times):

OP: Can you help me fix my 300 line program?

Adviser: Here's a way to write your program with 25 lines.

OP: Ok thanks, but I would like to debug my existing program


Other code newbies are fond of doing out of laziness:

while(true) {}

goto MyLabel;

main; //recursive call to main

if (x != '+' && x != '-' && x != '*' && x != '/') {}

1
2
3
4
float a = 0.1;
float b = 10 * a;

if(a == b) {}



It is important to try and differentiate between laziness & ignorance - although sometimes this is rather difficult.

EDIT: How could I forget my omnipresent request for code tags, Post compiler output, Read the documentation / reference, Use Google

Last edited on
I stop helping people as soon as they start PMing me. I don't know what it is, but people seem to think that PMing everyone that posted in their thread will help. If they do this, I lose all respect for them.
There's errors that can occur before you get to eof.
while(fin.good())
Is preferred.
The issue remains
1
2
3
4
5
6
while (good)
{
    attempt to read x 
    //failed to read
    mess with x
}
The classic `is reading the last element twice'

I don't understand what Duoas refers with `more sophisticated' but looping on the reading is what you need to do, so it would stop when it fails.
by instance while( input>>var )
so there is no c++ port opening commands? or something like that? (given my low level of understanding i dont really know how it works and cant ask a coherent question)
Last edited on
so there is no c++ port opening commands?


C++ is a general purpose language that is intended to target a vast array of hardware. As you know, the C++ spec doesn't require you to have a keyboard, or a monitor, and only in the most recent version (C++11) have they bitten the bullet and actually discussed the memory model.

Networking is inherently dependent on hardware and the OS, and is (and in my opinion rightly) shunted to APIs and libraries.
ahh okay so i get an api and bother some other apr related forum with windows to linux questions, kay see i didnt know that, i thought it could be like writing a file.

so unless i built my own operating system with c++ or communicate with the hardware with raw data.

that last one sounds tempting to look into, bet its waaay complicated
Beej's guide to networking is a good place to start. Under *nix, it is like writing to a file.
thanks moschops, perfect, shud move to *nix soon, looking foward to it
If you prefer high-level interaction, you can check out liblacewing - otherwise, if you prefer low-level, there's hundreds of libraries and some googling should find you the good ones. Try to use platform-independent ones though - even if you only need it for your platform, it's good to practice writing portable code.

That's another thing; I generally don't help people who try to do things only for their platform, and I especially don't help people who try to do things with the Console window (I generally discourage treating the console as anything but a debugging tool)
Last edited on
L B wrote:
I generally don't help people who try to do things only for their platform, and I especially don't help people who try to do things with the Console window (I generally discourage treating the console as anything but a debugging tool)

Well that's dumb. Not every program need to be cross-platform and not every program needs a GUI.
I agree with chrisname. Specially considering how much harder it is to produce portable code.
It's annoying when people ask questions they should be able to find the answers for on their own. It's also a bad habit to rely on random forum goers for basic information. It's better to get information directly from the source if you can.
What I mean is, I don't help people who want to know how to do windows-only things like creating shortcuts, and I don't help people who want to e.g. color the output of their console. I've decided to allow other people help them with that instead, with the intention that people who are more familiar with such things than me will help.
Last edited on
That sounds like you just don't help people with things you don't know how to do, which is perfectly reasonable. Before, it sounded like you don't help people with that stuff because you were morally opposed to it, which is dumb. Even if someone is making a cross-platform application, the Windows version might need to make shortcuts. If someone is making a graphical application with a console for debugging, they might still want coloured output (my RPG uses the console window for debug, info and error messages (all three of which are in different colours (grey, white and red respectively)) as well as for interaction with the game engine (like the console in many games, but since my game isn't fullscreen there's no need to reinvent the wheel, I can just use the normal console)). Even so, not every application needs to have their own GUI (don't forget that the console is really just a GUI displaying text), many wouldn't make sense with a GUI because they only need to process text.
Pages: 12