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
curs_scanw(3X)															    curs_scanw(3X)

NAME
scanw, wscanw, mvscanw, mvwscanw, vwscanw, vw_scanw - convert formatted input from a curses window SYNOPSIS
#include <curses.h> int scanw(char *fmt, ...); int wscanw(WINDOW *win, char *fmt, ...); int mvscanw(int y, int x, char *fmt, ...); int mvwscanw(WINDOW *win, int y, int x, char *fmt, ...); int vw_scanw(WINDOW *win, char *fmt, va_list varglist); int vwscanw(WINDOW *win, char *fmt, va_list varglist); DESCRIPTION
The scanw, wscanw and mvscanw routines are analogous to scanf [see scanf(3S)]. The effect of these routines is as though wgetstr were called on the window, and the resulting line used as input for sscanf(3). Fields which do not map to a variable in the fmt field are lost. The vwscanw and vw_scanw routines are analogous to vscanf. They perform a wscanw using a variable argument list. The third argument is a va_list, a pointer to a list of arguments, as defined in <stdarg.h>. RETURN VALUE
vwscanw returns ERR on failure and an integer equal to the number of fields scanned on success. Applications may use the return value from the scanw, wscanw, mvscanw and mvwscanw routines to determine the number of fields which were mapped in the call. PORTABILITY
The XSI Curses standard, Issue 4 describes these functions. The function vwscanw is marked TO BE WITHDRAWN, and is to be replaced by a function vw_scanw using the <stdarg.h> interface. The Single Unix Specification, Version 2 states that vw_scanw is preferred to vwscanw since the latter requires including <varargs.h>, which cannot be used in the same file as <stdarg.h>. This implementation uses <stdarg.h> for both, because that header is included in <curses.h>. Both XSI and The Single Unix Specification, Version 2 state that these functions return ERR or OK. Since the underlying scanf can return the number of items scanned, and the SVr4 code was documented to use this feature, this is probably an editing error which was introduced in XSI, rather than being done intentionally. Portable applications should only test if the return value is ERR, since the OK value (zero) is likely to be misleading. One possible way to get useful results would be to use a "%n" conversion at the end of the format string to ensure that something was processed. SEE ALSO
curses(3X), curs_getstr(3X), curs_printw(3X), scanf(3S) curs_scanw(3X)
All times are GMT -4. The time now is 04:57 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy