Can any one tell me an Input function that terminate by pressing
spacebar and not return key.
Functions like scanf,getchar,getc when invoked they allow whatever
typed after a space they terminate by pressing enter only.
I am using turboc++.
consider the following program in which 2 matrices are given by user.
for(i=0;i<rows;i++)
{
for(j=0;j<cols;j++)
{
if ('\n'==getchar())
break;
else
scanf("%d",& b[i][j]);
}
}
the matrix should be inputted in the form 1 2 3
4
5 6
7
8 9
So after each space j should be incremented.After each return i should
be incremented. 4 1734
In article <11**********************@g43g2000cwa.googlegroups .com>,
shan <sr**********@gmail.com> wrote: Can any one tell me an Input function that terminate by pressing spacebar and not return key. Functions like scanf,getchar,getc when invoked they allow whatever typed after a space they terminate by pressing enter only.
On most operating systems, by default, characters typed are not
available to the user until and end-of-line characters is typed.
Of course, there's a way to overcome this, but it depends on the
operating system and can't be done using just standard C functions.
So you need to ask on a newsgroup for the operating system you use.
I am using turboc++.
That sounds like a C++ compiler, but I imagine the situtation is the
same with C++.
-- Richard
In article <11**********************@g43g2000cwa.googlegroups .com>,
shan <sr**********@gmail.com> wrote: Can any one tell me an Input function that terminate by pressing spacebar and not return key. Functions like scanf,getchar,getc when invoked they allow whatever typed after a space they terminate by pressing enter only. I am using turboc++.
Allow me to be the first to say this - and I say it from the deepness of my
heart, with all the kindness and love one has come to associate with the
helpful posts you get in this newsgroup:
Not portable. Can't discuss it here. Blah, blah, blah.
shan wrote: Can any one tell me an Input function that terminate by pressing spacebar and not return key.
Standard C does not have one. You will have to ask in a group dedicated
to your system.
Functions like scanf,getchar,getc when invoked they allow whatever typed after a space they terminate by pressing enter only. I am using turboc++. consider the following program in which 2 matrices are given by user.
for(i=0;i<rows;i++) { for(j=0;j<cols;j++) { if ('\n'==getchar()) break; else scanf("%d",& b[i][j]); } }
the matrix should be inputted in the form 1 2 3 4 5 6 7 8 9 So after each space j should be incremented.After each return i should be incremented.
Do you really need to receive the input on a space? To me it looks like
you might as well use fgets to read a line at a time then process each
line as you receive it. This way it will be easier to handle errors.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.
"shan" <sr**********@gmail.com> writes: Can any one tell me an Input function that terminate by pressing spacebar and not return key.
See the C FAQ, question 19.1.
<http://www.eskimo.com/~scs/C-faq/top.html>
--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dawn Minnis |
last post by:
Hi (running Win xp and developing using Miracle C. Running applications in
windows command prompt)
I'm new to the group so be gentle with me. I am currently writing a C
program to perform...
|
by: Fao, Sean |
last post by:
Hello all,
As stated in another message, it's been a long time since I've done any
C coding and I'm not feeling comfortable that I'm doing this correctly.
Basically, I'd like to verify that my...
|
by: ais523 |
last post by:
I use this function that I wrote for inputting strings. It's meant to
return a pointer to mallocated memory holding one input string, or 0 on
error. (Personally, I prefer to use 0 to NULL when...
|
by: Martin Jørgensen |
last post by:
Hi,
I'm trying to move a matlab program into c language. For those who knows
matlab, this is the line I want to program in c:
hx(1:nx,1:ny) = 0; % nx=10, ny=10
It works on a 2-dimensional...
|
by: SLH |
last post by:
hi people. im trying to validate input received via a text area on an ASP
page before writing it to a database. i cant use client side javascript due
to policy, so it all has to happen on the...
|
by: Andrew Gentile |
last post by:
Hello,
I have been working on a program where I need to have a function
return an array. I found out that C doesn't do this, so now I am
trying to get the function to return a pointer to an...
|
by: kvnsmnsn |
last post by:
I've written the following Javascript file that includes an input text
field and an output text field, the latter of which is initialized to
zero. Each time the user enters a number in the input...
|
by: dmoran21 |
last post by:
Hi All, I am working on a program to take input from a txt file, do
some calculations, and then output the results to another txt file.
The program that I've written compiles fine for me, however,...
|
by: arnuld |
last post by:
I searched the c.l.c archives provided by Google as Google Groups with
"word input" as the key words and did not come up with anything good.
C++ has std::string for taking a word as input from...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |