473,394 Members | 1,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

how to know commandline is empty or not ??

hello.. everyone
i am writing a c++ program in Linux..
i am reading a line from commandline at run time using "getline(std::cin,str);". now, what i want is if i left the commandline as idle (terminal as idle), then i want to know that the commandline is empty... is it possible ???
any comment is appreciable..

thank you
Mar 13 '13 #1
4 1441
Banfa
9,065 Expert Mod 8TB
Not really, the problem is if you try to get data when there is nothing waiting the cin line waits for data to be input. None of the other methods on cin indicate that there is no data available.
Mar 13 '13 #2
thank you soo much @Banfa
But, is there any equivalent method in c++, like CommandLine BufferedReader in java ????
Mar 13 '13 #3
weaknessforcats
9,208 Expert Mod 8TB
The problem is that your program is not running while the input is requested. If the input never comes your program hangs forever.

You should be able to get your input using a separate thread to return the data entered. If the thread fails to return after a set period you could delete the thread and call that your "empty" command line.
Mar 13 '13 #4
Thank you @weaknessforcats
My program is running. The actual thing is that i want that the control have to do multiple tasks in my program. if i enter data in commandline and hit enter it wanna go to send function, read data and send. If i am not typing anything then it will be in receiving mode..( Like chat program). For this one i don't want to use threads, bcozz program becomes complex. that's why i questioned about commandline. Is there any possible ways ??
thank you !!
Mar 14 '13 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Stefan Weiss | last post by:
Hi. (this is somewhat similar to yesterday's thread about empty links) I noticed that Tidy issues warnings whenever it encounters empty tags, and strips those tags if cleanup was requested....
2
by: Christoph Borger | last post by:
Hello! I have wrote a windows service in vb.net. This service monitors the running processes with WMI and the Win32_Process class. Till last month all seems ok. But since the begin of september...
1
by: Bo Peng | last post by:
Dear list, I am using rpy, a python module to control statistical package R from python. Running the following commands >>> from rpy import * >>> r.plot(0) will pass command 'plot' to R...
14
by: cj | last post by:
What is string.empty used for? I can't say: if string.empty then I have to use: if string = "" then which is ok, I just want to know what .empty is for.
0
by: axlq | last post by:
While trying to learn the ins and outs of the php CURL library, I decided to write a php script that posts a form on the Chicago Board of Options (CBOE) web site, which returns an ASCII text file. ...
3
by: balakrishnan.dinesh | last post by:
hi frndz, As we know that, we can pass command line agrument for C using "scanf" commands, So as same as that, Is there any way to pass those commandline arguments through php code to C and...
2
by: andreas.huesgen | last post by:
Hello, I am writing a commandline tool in Python which is often feed with lots of commandline arguments. In practice, the commandline already reached a critical length which is to long for Windows...
1
by: KakaICE | last post by:
Hi, I am using Visual Studio 2005 The problem is: The parent.exe launches a child.exe executible. In the child.exe process I want to know the commandline with which parent.exe was originally...
87
by: rufus | last post by:
Is there a C-compiler (and for that matter C++ compiler) for windows that can be run from the commmand line?
8
HaLo2FrEeEk
by: HaLo2FrEeEk | last post by:
I'd like to write a program to assist me in upoloading files to my site. I know how to upload the files using C#, I just don't know how to have an interface and still accept commandline parameters. ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.