nixp.ru v3.0

29 марта 2024,
пятница,
16:00:03 MSK

spacer написал 27 июля 2005 года в 15:56 (908 просмотров) Ведет себя как мужчина; открыл 11 тем в форуме, оставил 36 комментариев на сайте.

Вичитал вот что возможно такое:

scanf("%[^\n]\n", s);
      %[^\n] - читать любые символы, кроме \n (до \n)
      \n     - пропустить \n на конце строки
      %[abcdef] - читать слово,
                  состоящее из перечисленных букв.
      %[^abcde] - читать слово из любых букв,
        кроме перечисленных (прерваться по букве из списка).

В манах подробностей не нашел. Мож ткете где по подробнее почитать?

sas

Quote from «man scanf»

[     Matches a nonempty sequence of characters from the specified set of
           accepted characters; the next pointer must be a pointer to char,
           and there must be enough room for all the characters in the string,
           plus a terminating NUL character.  The usual skip of leading white
           space is suppressed.  The string is to be made up of characters in
           (or not in) a particular set; the set is defined by the characters
           between the open bracket [ character and a close bracket ] charac-
           ter.  The set excludes those characters if the first character
           after the open bracket is a circumflex ^.  To include a close
           bracket in the set, make it the first character after the open
           bracket or the circumflex; any other position will end the set.
           The hyphen character - is also special; when placed between two
           other characters, it adds all intervening characters to the set.
           To include a hyphen, make it the last character before the final
           close bracket.  For instance, `[^]0-9-]' means the set ``everything
           except close bracket, zero through nine, and hyphen''.  The string
           ends with the appearance of a character not in the (or, with a cir-
           cumflex, in) set or when the field width runs out.
           If an l qualifier is present, the next pointer must be a pointer to
           wchar_t, into which the input will be placed after conversion by
           mbrtowc(3).
rgo

я все эти штучки, выяснял в info libc

Последние комментарии

ecobeingecobeing.ru
Экология и вегетарианство на благо всем живым существам Планеты.