473,498 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

scanf problem with intaking a string *PLS. HELP*

HI all;

I have created a program just to get an understanding of strcpy. (still an
amateur developer).

I use scanf("%s", &first) in order to get the input to the variable first
(which is char first[]).

Then I go strcpy(second, first). This is just to demonstrate the strcpy
function for myself and it (as far as I know) copies what's in first to
second.

The problem is: * When a user uses spaces in his/her input (e.g. "Hello
World")
--> Only "Hello" will be displayed.

Now I have made sure the array has ample size; I just dont know what's
wrong?

I unfortunately have deleted the source code by mistake (as I was
frustrated); so I can't supply it here; If y'all really need it I wouldn't
ming writing it out again but I think y'all can have a pretty good
understanding from my descriptions.

Please Help. Thanks a lot for it in advance.
Nov 15 '05 #1
18 1548
"Radith" <ra****@xtra.co.nz> writes:
I use scanf("%s", &first) in order to get the input to the variable first
(which is char first[]).

Then I go strcpy(second, first). This is just to demonstrate the strcpy
function for myself and it (as far as I know) copies what's in first to
second.

The problem is: * When a user uses spaces in his/her input (e.g. "Hello
World")
--> Only "Hello" will be displayed.


This is because %s only reads a single word. It will skip
leading white space, but after that white space causes it to stop
reading.
--
"When I have to rely on inadequacy, I prefer it to be my own."
--Richard Heathfield
Nov 15 '05 #2

"Radith" <ra****@xtra.co.nz> wrote

I use scanf("%s", &first) in order to get the input to the variable first
(which is char first[]).

scanf("%s", ptr);

will only read the first word (string of characters separated by whitespace)
into the bufer pointed to by ptr.
You can read a whole line with gets(). Unfortunately the function is flawed,
because the buffer will overrun, probably causing a crash, if the user types
in too many characters. fgets() is even worse if used incorrectly - input is
silently truncated. Why is that worse? Because wrong results are usually
worse than no results. However you can build a solid input function on top
of fgets(), but it is needlessly complicated.
So regrettably there is no easy way of getting a line from the user in ISO
C.

Nov 15 '05 #3
"Malcolm" <re*******@btinternet.com> writes:
"Radith" <ra****@xtra.co.nz> wrote

I use scanf("%s", &first) in order to get the input to the variable first
(which is char first[]).

scanf("%s", ptr);

will only read the first word (string of characters separated by whitespace)
into the bufer pointed to by ptr.
You can read a whole line with gets(). Unfortunately the function is flawed,
because the buffer will overrun, probably causing a crash, if the user types
in too many characters. fgets() is even worse if used incorrectly - input is
silently truncated. Why is that worse? Because wrong results are usually
worse than no results. However you can build a solid input function on top
of fgets(), but it is needlessly complicated.
So regrettably there is no easy way of getting a line from the user in ISO
C.


fgets() is worse than gets()?

Nonsense.

--
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.
Nov 15 '05 #4
> [snipped] If y'all really need it [snipped]

Is that your truck in MUD95?

Alright, alright, I'll start contributing serious responses again.

--
Martijn
http://www.sereneconcepts.nl
Nov 15 '05 #5
Keith Thompson wrote:
"Malcolm" <re*******@btinternet.com> writes:
"Radith" <ra****@xtra.co.nz> wrote
I use scanf("%s", &first) in order to get the input to the variable first
(which is char first[]).


scanf("%s", ptr);

will only read the first word (string of characters separated by whitespace)
into the bufer pointed to by ptr.
You can read a whole line with gets(). Unfortunately the function is flawed,
because the buffer will overrun, probably causing a crash, if the user types
in too many characters. fgets() is even worse if used incorrectly - input is
silently truncated. Why is that worse? Because wrong results are usually
worse than no results. However you can build a solid input function on top
of fgets(), but it is needlessly complicated.
So regrettably there is no easy way of getting a line from the user in ISO
C.

fgets() is worse than gets()?

Nonsense.


Well, in a way, it is: It is the closest you can get to a sensible
text input function but falls short, unnecessarily and nastily.
If you consider a function more broken which does not invoke UB
(and quite often segfaults to tell you where you went wrong)
instead of silently truncating and upsetting everything in a
hard-to-catch way, then you can arrive at this conclusion.
IMO, fgets() with sensible return values to communicate, say
EOF/Error/NoNewLineEncountered/NewLineEncountered, would be
quite alright.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 15 '05 #6
Michael Mair wrote:
Keith Thompson wrote:


<snip>


fgets() is worse than gets()?

Nonsense.


Well, in a way, it is: It is the closest you can get to a sensible
text input function but falls short, unnecessarily and nastily.
If you consider a function more broken which does not invoke UB
(and quite often segfaults to tell you where you went wrong)
instead of silently truncating and upsetting everything in a
hard-to-catch way, then you can arrive at this conclusion.

<snip>

Huh? UB nearly universally "[upsets] everything in a hard-to-catch
way". Even worse, it often results in security holes.

Well-defined but annoying behavior is certainly not worse, at least in
the sense of the word I am accustomed to.
Mark F. Haigh
mf*****@sbcglobal.net

Nov 15 '05 #7
On Mon, 01 Aug 2005 08:51:23 +0200, Michael Mair
<Mi**********@invalid.invalid> wrote:
Keith Thompson wrote:
"Malcolm" <re*******@btinternet.com> writes:
"Radith" <ra****@xtra.co.nz> wrote

I use scanf("%s", &first) in order to get the input to the variable first
(which is char first[]).
scanf("%s", ptr);

will only read the first word (string of characters separated by whitespace)
into the bufer pointed to by ptr.
You can read a whole line with gets(). Unfortunately the function is flawed,
because the buffer will overrun, probably causing a crash, if the user types
in too many characters. fgets() is even worse if used incorrectly - input is
silently truncated. Why is that worse? Because wrong results are usually
worse than no results. However you can build a solid input function on top
of fgets(), but it is needlessly complicated.
So regrettably there is no easy way of getting a line from the user in ISO
C.
fgets() is worse than gets()?

Nonsense.


Well, in a way, it is: It is the closest you can get to a sensible
text input function but falls short, unnecessarily and nastily.


OK, so it's not a perfect interface, lots of the C library isn't a
perfect interface. Whether it is 'necessary' to have had that interface
is a matter of opinion, but most of the I/O interface wasn't designed,
it "jest growed". It's certainly perfectly usable.
If you consider a function more broken which does not invoke UB
(and quite often segfaults to tell you where you went wrong)
instead of silently truncating and upsetting everything in a
hard-to-catch way, then you can arrive at this conclusion.
I have never had fgets() segfault, except when passing it invalid
parameters. How have you done it? If you give it a valid file pointer,
valid pointer to a data area and a correct length (no greater than the
size of the data area) then if it segfaults you have a faulty
implementation.

fgets() doesn't 'truncate', it simply stops inputting when the buffer is
full. Doing "if (strchr(buffer, '\n'))" will detect whether the line
was complete at that point (strlen() would do as well). You can then
decide whether you want to discard the rest of the data, increase the
buffer size, or whatever. If you don't bother testing then your program
is broken, no more or less than if you ignore returned status.
IMO, fgets() with sensible return values to communicate, say
EOF/Error/NoNewLineEncountered/NewLineEncountered, would be
quite alright.


All that information is available. You can call feof/ferror on the
input stream (fgets() will return NULL if it didn't get anything) and
you can test for newline as above.

Or of course you can write your own input function with the behaviour
you like, it's not hard (indeed, I've rewritten such functions many
times because it was faster than digging out the code I'd written
before).

Chris C
Nov 15 '05 #8
On Sun, 31 Jul 2005 16:36:11 +0000, Malcolm wrote:

"Radith" <ra****@xtra.co.nz> wrote

I use scanf("%s", &first) in order to get the input to the variable first
(which is char first[]).
scanf("%s", ptr);

will only read the first word (string of characters separated by whitespace)
into the bufer pointed to by ptr.
You can read a whole line with gets(). Unfortunately the function is flawed,
because the buffer will overrun, probably causing a crash, if the user types
in too many characters.


Correct.
fgets() is even worse if used incorrectly - input is
silently truncated. Why is that worse? Because wrong results are usually
worse than no results.
Often correct input has limited length. In which case fgets() (given a
suitable arguments) will only go "wrong" on invalid input, which is
perfectly reasonable.

Also you imply that gets() would give no results, which is wrong. fgets()
has well defined behaviour on too long input even if it isn't the
behaviour you want, gets() has undefined behaviour. Both can give results,
the difference is that with fgets() the results are well defined and quite
possibly recoverable, with gets() the whole program ceases to be
predictable. There is no sense in which fgets() is worse than gets().
However you can build a solid input function on top
of fgets(), but it is needlessly complicated.
So regrettably there is no easy way of getting a line from the user in ISO
C.


It is easy as long as you stipulate that valid lines must not exceed a
certain size. fgets() will still handle valid input fine and invalid input
in a controlled way.

Lawrence

Nov 15 '05 #9

Michael Mair wrote:
Keith Thompson wrote:
"Malcolm" <re*******@btinternet.com> writes:
"Radith" <ra****@xtra.co.nz> wrote

I use scanf("%s", &first) in order to get the input to the variable first
(which is char first[]).
scanf("%s", ptr);

will only read the first word (string of characters separated by whitespace)
into the bufer pointed to by ptr.
You can read a whole line with gets(). Unfortunately the function is flawed,
because the buffer will overrun, probably causing a crash, if the user types
in too many characters. fgets() is even worse if used incorrectly - input is
silently truncated. Why is that worse? Because wrong results are usually
worse than no results. However you can build a solid input function on top
of fgets(), but it is needlessly complicated.
So regrettably there is no easy way of getting a line from the user in ISO
C.

fgets() is worse than gets()?

Nonsense.


Well, in a way, it is: It is the closest you can get to a sensible
text input function but falls short, unnecessarily and nastily.
If you consider a function more broken which does not invoke UB
(and quite often segfaults to tell you where you went wrong)
instead of silently truncating and upsetting everything in a
hard-to-catch way, then you can arrive at this conclusion.
IMO, fgets() with sensible return values to communicate, say
EOF/Error/NoNewLineEncountered/NewLineEncountered, would be
quite alright.


Well, even though the function interface itself doesn't provide these
values, they can be tested for relatively easily:

if (fgets(buffer, sizeof buffer, stream))
{
if (strchr(buffer, '\n'))
{
/* NewLineEncountered */
}
else
{
/* NoNewLineEncountered */
}
}
else
{
if (feof(stream))
{
/* EOF */
}
else
{
/* Error */
}
}

I mean, The C Way is for the library to do ~90% of what you need it to,
and then fill in the rest by hand. No, I'm not bitter, really.

For all its flaws, fgets() has one chief advantage over gets() -- you
don't run the risk of crashing your program or opening a security hole
*every* time you call it.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.


Nov 15 '05 #10
Mark F. Haigh wrote:
Michael Mair wrote:
Keith Thompson wrote:


<snip>
fgets() is worse than gets()?

Nonsense.


Well, in a way, it is: It is the closest you can get to a sensible
text input function but falls short, unnecessarily and nastily.
If you consider a function more broken which does not invoke UB ^^^
one "not" too many :-(
(and quite often segfaults to tell you where you went wrong)
instead of silently truncating and upsetting everything in a
hard-to-catch way, then you can arrive at this conclusion.


<snip>

Huh? UB nearly universally "[upsets] everything in a hard-to-catch
way". Even worse, it often results in security holes.

Well-defined but annoying behavior is certainly not worse, at least in
the sense of the word I am accustomed to.


I just tried to explain how one might regard fgets() as worse than
gets() -- and failed.
Personally, I do not use either and work with getc()- or fread()-based
input or fscanf() if I feel daring.
What I meant is that it is sometimes easier to find a gets() gone wild
than a fgets() treading down the semantics.
The original statement did not come from me but I understand the
sentiment behind it very well.
Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 15 '05 #11
Chris Croughton wrote:
On Mon, 01 Aug 2005 08:51:23 +0200, Michael Mair
<Mi**********@invalid.invalid> wrote:
Keith Thompson wrote:
"Malcolm" <re*******@btinternet.com> writes:

"Radith" <ra****@xtra.co.nz> wrote

>I use scanf("%s", &first) in order to get the input to the variable first
>(which is char first[]).

scanf("%s", ptr);

will only read the first word (string of characters separated by whitespace)
into the bufer pointed to by ptr.
You can read a whole line with gets(). Unfortunately the function is flawed,
because the buffer will overrun, probably causing a crash, if the user types
in too many characters. fgets() is even worse if used incorrectly - input is
silently truncated. Why is that worse? Because wrong results are usually
worse than no results. However you can build a solid input function on top
of fgets(), but it is needlessly complicated.
So regrettably there is no easy way of getting a line from the user in ISO
C.

fgets() is worse than gets()?

Nonsense.
Well, in a way, it is: It is the closest you can get to a sensible
text input function but falls short, unnecessarily and nastily.


OK, so it's not a perfect interface, lots of the C library isn't a
perfect interface. Whether it is 'necessary' to have had that interface
is a matter of opinion, but most of the I/O interface wasn't designed,
it "jest growed". It's certainly perfectly usable.


'Tis, for some values of "perfectly".
If you consider a function more broken which does not invoke UB ^^^
one "not" too many :-(
(and quite often segfaults to tell you where you went wrong)
instead of silently truncating and upsetting everything in a
hard-to-catch way, then you can arrive at this conclusion.


I have never had fgets() segfault, except when passing it invalid
parameters. How have you done it? If you give it a valid file pointer,
valid pointer to a data area and a correct length (no greater than the
size of the data area) then if it segfaults you have a faulty
implementation.


Umh, see above (one not too many) and <3l*************@individual.net>,
my reply to Mark F. Haigh.
I head gets() segfault in other people's code which was much easier
to find than fgets()-related problems.
fgets() doesn't 'truncate', it simply stops inputting when the buffer is
full. Doing "if (strchr(buffer, '\n'))" will detect whether the line
was complete at that point (strlen() would do as well). You can then
decide whether you want to discard the rest of the data, increase the
buffer size, or whatever. If you don't bother testing then your program
is broken, no more or less than if you ignore returned status.


This is, as in <3l*************@individual.net> mentioned, the reason
why I do not use fgets()...
IMO, fgets() with sensible return values to communicate, say
EOF/Error/NoNewLineEncountered/NewLineEncountered, would be
quite alright.


All that information is available. You can call feof/ferror on the
input stream (fgets() will return NULL if it didn't get anything) and
you can test for newline as above.

Or of course you can write your own input function with the behaviour
you like, it's not hard (indeed, I've rewritten such functions many
times because it was faster than digging out the code I'd written
before).


Yep, and usually, getc() based input code is clearer than catching all
the indirect error returns of fgets().

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 15 '05 #12
John Bode wrote:
Michael Mair wrote:
Keith Thompson wrote:
"Malcolm" <re*******@btinternet.com> writes:

"Radith" <ra****@xtra.co.nz> wrote

>I use scanf("%s", &first) in order to get the input to the variable first
>(which is char first[]).

scanf("%s", ptr);

will only read the first word (string of characters separated by whitespace)
into the bufer pointed to by ptr.
You can read a whole line with gets(). Unfortunately the function is flawed,
because the buffer will overrun, probably causing a crash, if the user types
in too many characters. fgets() is even worse if used incorrectly - input is
silently truncated. Why is that worse? Because wrong results are usually
worse than no results. However you can build a solid input function on top
of fgets(), but it is needlessly complicated.
So regrettably there is no easy way of getting a line from the user in ISO
C.

fgets() is worse than gets()?

Nonsense.


Well, in a way, it is: It is the closest you can get to a sensible
text input function but falls short, unnecessarily and nastily.
If you consider a function more broken which does not invoke UB
(and quite often segfaults to tell you where you went wrong)
instead of silently truncating and upsetting everything in a
hard-to-catch way, then you can arrive at this conclusion.
IMO, fgets() with sensible return values to communicate, say
EOF/Error/NoNewLineEncountered/NewLineEncountered, would be
quite alright.


Well, even though the function interface itself doesn't provide these
values, they can be tested for relatively easily:

if (fgets(buffer, sizeof buffer, stream))
{
if (strchr(buffer, '\n'))
{
/* NewLineEncountered */
}
else
{
/* NoNewLineEncountered */
}
}
else
{
if (feof(stream))
{
/* EOF */
}
else
{
/* Error */
}
}

I mean, The C Way is for the library to do ~90% of what you need it to,
and then fill in the rest by hand. No, I'm not bitter, really.

For all its flaws, fgets() has one chief advantage over gets() -- you
don't run the risk of crashing your program or opening a security hole
*every* time you call it.


Thanks for writing it out. See my other two replies to see how my
explanation failed to make sense.
However, the above demonstrates why so many people use fgets() in
the wrong way :-/ As mentioned before: getc() produces clearer code.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 15 '05 #13
Michael Mair <Mi**********@invalid.invalid> writes:
[...]
I just tried to explain how one might regard fgets() as worse than
gets() -- and failed.
Personally, I do not use either and work with getc()- or fread()-based
input or fscanf() if I feel daring.
What I meant is that it is sometimes easier to find a gets() gone wild
than a fgets() treading down the semantics.
The original statement did not come from me but I understand the
sentiment behind it very well.


There are two separate issues here.

The first is that gets() is broken, and cannot be used safely.
It should be removed from the language (in my opinion, and in the
opinion of many others).

The second is that fgets() has some problems, and can be used either
correctly or incorrectly.

fgets() may be a problem, but gets() is certainly not the solution.

--
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.
Nov 15 '05 #14
Michael Mair wrote:
John Bode wrote:
.... snip ...

Well, even though the function interface itself doesn't provide
these values, they can be tested for relatively easily:
/* minor editing to emphasize 3 major possibilities - cbf */ if (fgets(buffer, sizeof buffer, stream)) {
if (strchr(buffer, '\n')) {
/* NewLineEncountered */
}
else {
/* NoNewLineEncountered */
}
}
else if (feof(stream)) {
/* EOF */
}
else {
/* Error */
}

.... snip ... However, the above demonstrates why so many people use fgets() in
the wrong way :-/ As mentioned before: getc() produces clearer code.


My ggets package uses fgets for actual input, but could just as
well use getc. In some systems the results may be more efficient,
depending primarily on whether getc is actually a macro operating
directoy on the stream buffer. However that is not likely to
matter in a function used primarily for interactive input. It
might well reduce the volume of library code needed to link.

To me ggets presents the right interface. It is simple, it always
gets complete lines, and the terminal '\n' is always stripped. Its
error return allows for malloc failure, completion, and the EOF or
error condition (which the user can separate if needed).

int ggets(char **line);
or
int fggets(char **line, FILE *f);

--
Chuck F (cb********@yahoo.com) (cb********@worldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net> USE worldnet address!
Nov 15 '05 #15
Keith Thompson wrote:

<snip>

fgets() may be a problem, but gets() is certainly not the solution.


Well put. That'll go in the quotes file.
Mark F. Haigh
mf*****@sbcglobal.net

Nov 15 '05 #16
John Bode wrote:


Well, even though the function interface itself doesn't provide these
values, they can be tested for relatively easily:

if (fgets(buffer, sizeof buffer, stream))
{
if (strchr(buffer, '\n'))
Sure that works but it's horribly inefficient. What if buffer
is 2M in length, why should the program have to (re)scan it
when fgets knew perfectly well that it truncated the buffer? Clearly
a sane replacement for fgets would return a status
value indicating that the truncation took place. I often
wonder just what the designer of fgets was thinking when he
(she?) chose the return value. Clearly a simple int
return value something like this would have worked much
better:
=0 number of characters read (EOL character stripped)

-1 EOF
-2 Read Error
-3 Buffer Full
(or
N+1 Buffer Full, where N is the number of characters in the buffer)

Even more amazing to me is that subsequent C standards have not
introduced this "sfgets" (sane fgets) so that future C code
wouldn't be forever hobbled by the poor design choices made for fgets.

Regards,

David Mathog
ma****@caltech.edu
Nov 15 '05 #17
David Mathog wrote:
John Bode wrote:
Well, even though the function interface itself doesn't provide
these values, they can be tested for relatively easily:

if (fgets(buffer, sizeof buffer, stream))
{
if (strchr(buffer, '\n'))


Sure that works but it's horribly inefficient. What if buffer
is 2M in length, why should the program have to (re)scan it
when fgets knew perfectly well that it truncated the buffer?
Clearly a sane replacement for fgets would return a status
value indicating that the truncation took place. I often
wonder just what the designer of fgets was thinking when he
(she?) chose the return value. Clearly a simple int
return value something like this would have worked much
better:
>=0 number of characters read (EOL character stripped)

-1 EOF
-2 Read Error
-3 Buffer Full
(or
N+1 Buffer Full, where N is the number of characters in the
buffer)

Even more amazing to me is that subsequent C standards have not
introduced this "sfgets" (sane fgets) so that future C code
wouldn't be forever hobbled by the poor design choices made for
fgets.


Don't worry about it. Just get and use the portable public domain:

<http://cbfalconer.home.att.net/download/ggets.zip>

--
"If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 15 '05 #18
CBFalconer wrote:
Michael Mair wrote:
John Bode wrote:


... snip ...
Well, even though the function interface itself doesn't provide
these values, they can be tested for relatively easily:

/* minor editing to emphasize 3 major possibilities - cbf */
if (fgets(buffer, sizeof buffer, stream)) {
if (strchr(buffer, '\n')) {
/* NewLineEncountered */
}
else {
/* NoNewLineEncountered */
}
}
else if (feof(stream)) {
/* EOF */
}
else {
/* Error */
}


... snip ...
However, the above demonstrates why so many people use fgets() in
the wrong way :-/ As mentioned before: getc() produces clearer code.

My ggets package uses fgets for actual input, but could just as
well use getc. In some systems the results may be more efficient,
depending primarily on whether getc is actually a macro operating
directoy on the stream buffer. However that is not likely to
matter in a function used primarily for interactive input. It
might well reduce the volume of library code needed to link.

To me ggets presents the right interface. It is simple, it always
gets complete lines, and the terminal '\n' is always stripped. Its
error return allows for malloc failure, completion, and the EOF or
error condition (which the user can separate if needed).

int ggets(char **line);
or
int fggets(char **line, FILE *f);


To complete the advertisement:

<http://cbfalconer.home.att.net/download/ggets.zip>

It is certainly a nice, portable and available replacement.

Cheers
Michael
--
E-Mail: Mine is an /at/ gmx /dot/ de address.
Nov 15 '05 #19

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3862
by: Eduardo Olivarez | last post by:
The following code does not work correctly on my machine. Either one of the scanf()'s alone work perfectly. However, when they are combined, the second scanf() call just reads what the first one...
20
2871
by: Sivarn | last post by:
I'm writing a program for that takes dates as input using scanf. I want to verify that the user is inputting a full 4 digits for the year. How do I do this? I know that the return value on printf...
7
7637
by: hugo27 | last post by:
obrhy8 June 18, 2004 Most compilers define EOF as -1. I'm just putting my toes in the water with a student's model named Miracle C. The ..h documentation of this compiler does state that when...
17
3471
by: Lefty Bigfoot | last post by:
Hello, I am aware that a lot of people are wary of using scanf, because doing it improperly can be dangerous. I have tried to find a good tutorial on all the ins and outs of scanf() but been...
3
18799
by: sosij.morris | last post by:
Hi. I'm trying to find some tutorial-type information on using scanf's regular-expression subset for parsing - to no avail so far. I've looked through quite a few posts to clc, but none that...
14
13742
by: main() | last post by:
I know this is the problem that most newbies get into. #include<stdio.h> int main(void) { char a; scanf("%c",&a); /*1st scanf */ printf("%c\n",a); scanf("%c",&a); /*2nd scanf*/...
7
4859
by: vamshi | last post by:
main() { char str; printf("Enter a string: "); scanf("%",str); printf("%",str); } Can some one help me with this code? when i tried to execute this..... it reads the string untill character
68
4550
by: stasgold | last post by:
Hello. I maybe reinvent the weel ... I'm trying to read positive integer number with the help of scanf, if the input value is not positive number but negaive one zero or char , i have to reread...
26
4487
by: tesh.uk | last post by:
Hi Gurus, I have written the following code with the help of Ivor Horton's Beginning C : // Structures, Arrays of Structures. #include "stdafx.h" #include "stdio.h" #define MY_ARRAY 15
0
7125
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
7165
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,...
1
6887
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...
1
4910
isladogs
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...
0
4590
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.