473,396 Members | 1,891 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,396 software developers and data experts.

Issue with while loop

1
hey guys,

I'm new to programming so please bare with me. My problem is that how do i scan/read a blank space? My WHILE loop terminates by typing "exit" no probs there, but when I need to keep the loop running i have to press "ENTER" key to continue running. How can I scan/read "ENTER" key?

Here's my while loop...

while (strcmp(end, "exit")!=0)

any suggestions? is there something I have missed out?
Thanks
Sep 25 '07 #1
3 1599
oler1s
671 Expert 512MB
Pressing the enter key is like typing "a" or "b" or "z" on the keyboard. It causes the operating system to insert a character, or series of characters, depending on the operating system, to insert a newline. As the name suggests, this newline character is interpreted as creating a newline. But is an actual character, and in C it is represented by '\n'.

Note that to type anything for the program, you need to type all the letters, numbers, spaces, whatever, and then press the enter key. So yes, in your programs, you always, always, always keep entering that newline character. Depending on your program, you may have been discarding that character or ignoring it, but it exists, and you need to account for its existence.

Before you do anything with whitespace processing, can I see more code? You should be doing something like taking input with fgets, and then processing the input as you see fit.
Sep 26 '07 #2
ashitpro
542 Expert 512MB
ascii value for ENTER is 10
you can read it by following code

scanf("%c",&d);
here d is of type char.

(int)d;

will give you the ascii value for ENTER
Sep 26 '07 #3
oler1s
671 Expert 512MB
So your idea of reading in a character is to read in an integer and then coerce it to a character? Wonder what that string and character format specifier in scanf is used for...
Sep 27 '07 #4

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

Similar topics

9
by: Tom Carrick | last post by:
Hi, In my attempted learning of python, I've decided to recode an old anagram solving program I made in C++. The C++ version runs in less than a second, while the python takes 30 seconds. I'm...
10
by: Eric | last post by:
I'm looking at this page in the MSDN right here: ms-help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfsystemcollectionsarraylist classsynchronizedtopic2.htm (or online here:...
2
by: Stressed Out Developer | last post by:
We have an application that has a 200 count loop that does the following: ' Each time thru the loop we pass the next IP Address is a range (aka 192.168.4.50 thru 192.168.4.254) Try If...
2
by: Praveen_db2 | last post by:
Hi All db2 V 8.1.3 Windows I have an application which processes some rows using an SP.There are 2 approaches to this issue. 1) I can call the SP once and pass all the rows together as CLOB.(Rows...
0
by: matchine | last post by:
This is a recommendation based on my research on an issue with the transfer text functionality. The comments below were from a tech I approched for help. "The transfer text process blocked...
3
by: gmac63 | last post by:
To be brief, I have never encountered this where I make a database query: <?php $db = sqlite_open('tc.db'); $result = sqlite_query($db,"select dir,app,protocol,sport,dport,mark from...
29
by: ataanis | last post by:
Hi, I have the following statement, and i'm trying to understand why when I do the second print it's giving me segmentation fault, both name and s_aliases are char arrays e.g THE FIRST PRINT...
1
by: Ryan | last post by:
Hello. I was hoping that someone may be able to assist with an issue that I am experiencing. I have created an Access DB which imports an Excel File with a particular layout and field naming. ...
10
by: igor | last post by:
I have recently discovered that the system.Timers.Timer from.Net Framework v1.1 is not reliable when used on Windows 2003 server. When incorporated into a Windows Service, the timer_elapsed event...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.