You are here:

C++/weather a line contain NULL or not


QUESTION: i took a line using ,

 cin.getline (line[0],200);

now i want to know that if

 line[0] contain a NULL or not.  (Ctrl + z)

please tell me what can i do

ANSWER: line[0] contains NUL (char - not NULL which is a pointer) if nothing is entered except Enter (newline).  If you enter Hello and a newline, then line[5] is NUL.  Finally, NUL is not Ctrl+Z.

Follow up:

Please try to ask your question again so I can understand the question.  I'd like to help if I can.


---------- FOLLOW-UP ----------

QUESTION: sorry i could not make you understand my question and of course that is my fault. so now the thing is

NUL is not Ctrl+Z : i know about it, but what i exactly want to do is, i want to take as many line as i want then when i think i want stop taking further input i will press the button Ctrl+Z(^z it shows on the screen )
and then press Enter button which will make me stop taking any further input. so now please tell what i need to perform this operation.

There is no built-in C function to do this.  Since you want to wait for a Ctrl+Z and Enter you have to read each character at a time storing them and checking for Ctrl+Z and Enter.

Follow up: How about the student teach the expert, so to speak, and show me what you found?  Otherwise, your poor rating is out of line.  It would help me to see what the question is you are really asking.



All Answers

Answers by Expert:

Ask Experts


Bill A


I can answer questions about C++, programming algorithms, Windows programming in MFC (which is C++). I cannot answer questions about STL (templates) and I have no experience with Linux. I do enjoy reviewing code and critiquing it or finding problems in it. I will also gladly show better algorithms or methods if you want to take advantage of that.


I've developed a commercial embedded C compiler/assembler and IDE with debugger toolset, of which the IDE and debugger are written in C++. I work in the industry writing high tech embedded programs and Windows programs to communicate with the embedded devices.

Book: Embedded Systems Design using the Rabbit 3000 Microprocessor Authored Chapter 10 in its entirety.

BS Computer Engineering

©2016 All rights reserved.