Sponsored Content
Full Discussion: fgets()
Top Forums Programming fgets() Post 27998 by wolk on Tuesday 10th of September 2002 11:18:16 PM
Old 09-11-2002
why complicate the simple stuff...?
why don't u use :

scanf("%s",&x );

where x is declared as pointer to char (char* x)
I assume that the command is in string format, if it is a int, it will look like:

scanf("%d",&x);

where x is a int

good luck!
by wolk!
 

6 More Discussions You Might Find Interesting

1. Programming

Problem with fgets and rewind function ..

Hello Friends, I got stuck with fgets () & rewind() function .. Please need help.. Actually I am doing a like, The function should read lines from a txt file until the function is called.. If the data from the txt file ends then it goes to the top and then again when the function is called... (1 Reply)
Discussion started by: user_prady
1 Replies

2. Programming

Question about NULL Character & fgets()

Assume client send the message " Hello ", i get output such as Sent mesg: hello Bytes Sent to Client: 6 bytes_received = recv(clientSockD, data, MAX_DATA, 0); if(bytes_received) { send(clientSockD, data, bytes_received, 0); data = '\0';... (2 Replies)
Discussion started by: f.ben.isaac
2 Replies

3. Programming

[C] fgets problem with SIGINT singlal!!!

Hi all, I have this method to read a string from a STDIN: void readLine(char* inputBuffer){ fgets (inputBuffer, MAX_LINE, stdin); fflush(stdin); /* remove '\n' char from string */ if(strlen(inputBuffer) != 0) inputBuffer = '\0'; } All work fine but if i... (1 Reply)
Discussion started by: hurricane86
1 Replies

4. Programming

fgets problems

I've been having trouble with reading past the end-of-file in C. Can anyone find my stupid mistake? This is the minimal code needed to cause the error for me: FILE *f = fopen(name, "r"); if (!f) return; pari_sp ltop = avma; char line; while(fgets(line, 1100, f) != NULL) printf(".");... (23 Replies)
Discussion started by: CRGreathouse
23 Replies

5. Programming

fgets problems newline

hello, i'm trying to write a C-program that reads a file line by line. (and searches each line for a given string) This file is an special ASCII-database-file, with a lot of entries. I checked the line with most length, and it was about 4000 characters. With google i found several... (4 Replies)
Discussion started by: p1cm1n
4 Replies

6. Programming

fgets read file line with "\n" inside

Hi, I have a string like this, char str ="This, a sample string.\\nThis is the second line, \\n \\n, we will have one blank line"; if I want to use strtok() to seperate the string, which token should I use? I tried "\n", "\\n", either not working. peter (1 Reply)
Discussion started by: laopi
1 Replies
scanf(3int)															       scanf(3int)

Name
       scanf, fscanf, sscanf - convert formatted input

Syntax
       #include <stdio.h>

       int scanf( format [, pointer ] ...  )
       char *format;

       int fscanf( stream, format [, pointer ] ...  )
       FILE *stream;
       char *format;

       int sscanf( s, format [, pointer ] ...  )
       char *s, *format;

Description
       The  international functions and are similar to the standard I/O functions. The difference is that the international functions allow you to
       use the %digit$ conversion character in place of the I% character you use in the standard I/O functions. The digit is  a  decimal  digit  n
       from 1 to 9.  The international functions apply conversions to the n th argument in the argument list, rather than to the next unused argu-
       ment.

       You can use % conversion character in the international functions.  However, you cannot mix the % conversion  character	with  the  %digit$
       conversion character in a single call.

       In  all	cases,	uses the radix character and collating sequence that is defined by the last successful call to category or If the radix or
       collating sequence is undefined, the function uses the C locale definitions.

   International Environment
       LC_COLLATE     Contains the user requirements for language, territory, and codeset for the character collation format.  affects the  behav-
		      ior  of regular expressions and the string collation functions in If is not defined in the current environment, provides the
		      necessary default.

       LC_NUMERIC     If this environment is set and valid, uses the international language database named in the definition  to  determine  radix
		      character rules.

       LANG	      If  this environment variable is set and valid uses the international language database named in the definition to determine
		      collation and character classification rules.  If or is defined,	their definitions supersede the definition of LANG.

Examples
       The following shows an example of using the function:
       scanf("%2$s %1$d", integer, string)
       If the input is `` january 9 '', the function assigns 9 to and ``january'' to

Return Values
       The function returns the number of successfully matched and assigned input fields.  This number can be  zero  if  the  function	encounters
       invalid input characters, as specified by the conversion specification, before it can assign input characters.

       If  the	input ends before the first conflict or conversion, returns EOF.  These functions return EOF on end of input and a short count for
       missing or invalid data items.

Environment
       In POSIX mode, the E, F, and X formats are treated the same as the e, f, and x formats, respectively;  otherwise,  the  upper-case  formats
       expect double, double, and long arguments, respectively.

See Also
       intro(3int), setlocale(3), strtod(3), strtol(3), printf(3int), getc(3s), printf(3s), scanf(3s)
       Guide to Developing International Software

																       scanf(3int)
All times are GMT -4. The time now is 08:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy