473,498 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

scanf right square bracket

I want use scanf to read from input everything till right square
bracket ']'.

It seems to be something like that:
scanf("%[^\]]) but that's not working.

Any ideas?

May 4 '07 #1
1 5681
pr*********@gmail.com wrote:
I want use scanf to read from input everything till right square
bracket ']'.

It seems to be something like that:
scanf("%[^\]]) but that's not working.

Any ideas?
A couple. First, 'comp.lang.c' is a [marginally] better place
to ask about the functionality of C standard library functions.
Second, have you tried using 'getline' and parse the input line
yourself? 'string' has plenty of functionality to locate your ']'
and trim the input. Third, the C standard says that the right
bracket has to be the first in your sequence to be considered in
it, IOW, the sequence has to be "%[^]]" if you want to read any
character up to the bracket.

#include <cstdio>
int main()
{
char c[10] = {}, s[] = "123]321";
int i = sscanf(s, "%[^]]", c);
printf("scanned %d fields, c = <%s>\n", i, c);
}

Should print
scanned 1 fields, c = <123>

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
May 4 '07 #2

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

Similar topics

1
6390
by: Veverita | last post by:
Hi there I'm hoping that someone can help me with a question I have about javascript syntax. I got an html page that uploads an image and some text field to a database. What I'd like to do...
37
5218
by: Philipp Lenssen | last post by:
Using a combination of HTML and CSS, what is the right way to quote? I'm using this in my blog: <p>My text.</p> <p><q>"This is a quotation."<br /> <cite>-- John</cite></q> </p>
1
1916
by: Nalpo | last post by:
Hi, i want to update several Textboxes by reading the value of another Box. For that i use the following small script: <form name="form1" method="POST"> <input type="text" name="xx" value ="1"...
9
5556
by: Christine | last post by:
It has come to my attention that sometimes, when I open a Query in SQL View, the SQL that I see is not exactly the same as the SQL in the Query's Querydef. The difference I see (only occasionally)...
8
3742
by: regis | last post by:
Greetings, about scanf matching nonempty sequences using the "%" matches a nonempty sequence of anything except '-' "%" matches a nonempty sequence of anything except ']" matches a nonempty...
2
5207
by: Bernard Liang | last post by:
In response, I have another question about the scanf family. After reading in a %d value, for instance, do they immediately wade through all subsequent whitespace until a non-whitespace character...
3
18799
by: sosij.morris | last post by:
Hi. I'm trying to find some tutorial-type information on using scanf's regular-expression subset for parsing - to no avail so far. I've looked through quite a few posts to clc, but none that...
68
4550
by: stasgold | last post by:
Hello. I maybe reinvent the weel ... I'm trying to read positive integer number with the help of scanf, if the input value is not positive number but negaive one zero or char , i have to reread...
3
2916
by: balakrishnan.dinesh | last post by:
Hi frnds, Im having a problem in searching out a particular substring in a string. Here the code: --------------------- <html> <script> var tmpString=" ";
0
7121
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6993
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7162
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7197
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7375
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4899
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4584
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3088
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.