472,958 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Syntax question

Hi!
The syntax of fputs() is similar with the syntax of fgets();
For example
if we have:fgets(str,maxlen,stdin)
which is the syntax of the fputs();

Jul 10 '06 #1
11 5123
de*****@hotmail.com said:
Hi!
The syntax of fputs() is similar with the syntax of fgets();
For example
if we have:fgets(str,maxlen,stdin)
which is the syntax of the fputs();
See page 247 of "The C Programming Language", 2nd edition, by Kernighan and
Ritchie.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jul 10 '06 #2
de*****@hotmail.com wrote:
Hi!
The syntax of fputs() is similar with the syntax of fgets();
For example
if we have:fgets(str,maxlen,stdin)
which is the syntax of the fputs();
int fputs(const char *s, FILE *stream);

The function accesses characters from C string s and writes them to the
output stream stream. The function does not write the terminating null
character. It returns a nonnegative value if it has not set the error
indicator; otherwise, it returns EOF.

stdin: #define stdin <pointer to FILE rvalue>

The macro yields a pointer to the object that controls the standard
input stream.

Writing such a string to stdin may not make a whole lot of sense.

Perhaps rephrase your question?
Jul 10 '06 #3
Perhaps rephrase your question?

When we have for example:
printf("Dwste to onoma sas");
gets(name);

In which way can i see in the screen the name that i have inserted;
One way is for example puts(name). Right;
How can i do it this with the fputs();

Jul 10 '06 #4
Op 10 Jul 2006 09:41:11 -0700 schreef de*****@hotmail.com:
Hi!
The syntax of fputs() is similar with the syntax of fgets();
For example
if we have:fgets(str,maxlen,stdin)
which is the syntax of the fputs();
man fputs
--
Coos
Jul 10 '06 #5
de*****@hotmail.com wrote:
>Perhaps rephrase your question?

When we have for example:
printf("Dwste to onoma sas");
gets(name);

In which way can i see in the screen the name that i have inserted;
One way is for example puts(name). Right;
How can i do it this with the fputs();
I don't think stdio works the way I think you say it does, at least not
portably. Then again, I may have an incomplete understanding of what
you are trying to achieve. Perhaps post some code that compiles cleanly
that shows your "one way" you know works.
Jul 10 '06 #6
>Perhaps post some code that compiles cleanly
that shows your "one way" you know works.

Let's see a small code with puts.

#include<stdio.h>

char *messages[5]={"This","is","a","short","message."};

main()
{
int x;
for(x=0;x<5;x++)
puts(messages[x]);

puts("And this is the end!");

return 0;
}

Having seen this programm can you tell me how can i may it with
fputs();I hope to cover you with this small programm.

Jul 10 '06 #7
In article <11**********************@h48g2000cwc.googlegroups .com>,
<de*****@hotmail.comwrote:
>When we have for example:
printf("Dwste to onoma sas");
gets(name);
In which way can i see in the screen the name that i have inserted;
One way is for example puts(name). Right;
How can i do it this with the fputs();
fputs(name, stdout);

--
I was very young in those days, but I was also rather dim.
-- Christopher Priest
Jul 10 '06 #8
de*****@hotmail.com wrote:
>Perhaps post some code that compiles cleanly
that shows your "one way" you know works.


Let's see a small code with puts.

#include<stdio.h>

char *messages[5]={"This","is","a","short","message."};

main()
{
int x;
for(x=0;x<5;x++)
puts(messages[x]);

puts("And this is the end!");

return 0;
}

Having seen this programm can you tell me how can i may it with
fputs();I hope to cover you with this small programm.
These lines are _nearly_ equivalent:

fputs(messages[x], stdout);
[...]
fputs("And this is the end!", stdout);

Though you will note that there is no implicit newline sent to stdout
via fputs().
Jul 10 '06 #9
On 2006-07-10, de*****@hotmail.com <de*****@hotmail.comwrote:
>Perhaps rephrase your question?

When we have for example:
printf("Dwste to onoma sas");
gets(name);

In which way can i see in the screen the name that i have inserted;
One way is for example puts(name). Right;
How can i do it this with the fputs();
How did you make `name' an infinite array?

--
Andrew Poelstra <http://www.wpsoftware.net/projects/>
To email me, use "apoelstra" at the above domain.
"You people hate mathematics." -- James Harris
Jul 10 '06 #10

de*****@hotmail.com wrote:
Perhaps rephrase your question?

When we have for example:
printf("Dwste to onoma sas");
gets(name);
*Please* don't ever use gets(); it will introduce a point of failure in
your code (specifically, it will make your code vulnerable to buffer
overruns, which is a common security hole). Use fgets() instead:

fgets(name, sizeof name, stdin); // buffer, buffer size, input
stream

Seriously, pretend you never knew gets() ever existed.
>
In which way can i see in the screen the name that i have inserted;
One way is for example puts(name). Right;
How can i do it this with the fputs();
fputs(name, stdout); // or some other output stream

Jul 10 '06 #11
de*****@hotmail.com writes:
The syntax of fputs() is similar with the syntax of fgets();
For example
if we have:fgets(str,maxlen,stdin)
which is the syntax of the fputs();
The syntax of a call to fputs() is the same as the syntax of any
function call. But you probably want to know more than just the
syntax; you want to know how to use it.

You should have some form of documentation for the functions in the C
standard library. On some systems, the "man" command will show you
this documentation. On others, there may be something called a "help"
system, or possibly an "info" command.

If you're learning to program in C, you should have a text book; look
up "fputs" in its index. If you don't have a text book, you need to
get one. One of the best tutorials is K&R2 (Kernighan & Ritchie, _The
C Programming Language_, 2nd edition).

I have a number of such resources myself; if I didn't, the first thing
I'd try is a Goole search for "fputs". (Ignore the references to PHP;
that's a different language, and apparently it has a function with the
same name.)

Your question is a very elementary one. If you have some resource
where you can look up things like this, you won't need to post such
questions here. If you don't have such a resource, it's going to be
very difficult to learn C.

--
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.
Jul 10 '06 #12

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

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
4
by: Aaron Walker | last post by:
Greetings, I'm attempting to write my first *real* template function that also deals with a map of strings to member function pointers that is making the syntax a little tricky to get right. ...
2
by: bor_kev | last post by:
Hi, First of all, i want to use the new managed class syntax and STL.NET under Microsoft Visual (C++) Studio 2005 Beta. I read in a Microsoft...
5
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
3
by: astromog | last post by:
I have some significantly extended syntax for Python that I need to create a reference implementation for. My new syntax includes new keywords, statements and objects that are sort of like classes...
8
by: Smithers | last post by:
Are there any important differences between the following two ways to convert to a type?... where 'important differences' means something more profound than a simple syntax preference of the...
2
by: berrylthird | last post by:
This question was inspired by scripting languages such as JavaScript. In JavaScript, I can access members of a class using array syntax as in the following example: var myInstance:myClass = new...
17
by: trose178 | last post by:
Good day all, I am working on a multi-select list box for a standard question checklist database and I am running into a syntax error in the code that I cannot seem to correct. I will also note...
6
by: Daniel | last post by:
I hope this question is OK for this list. I've downloaded Rpyc and placed it in my site packages dir. On some machines it works fine, on others not so much. Here is one error I get when I try...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.