473,385 Members | 1,312 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,385 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 5170
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($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
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...

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.