473,320 Members | 1,921 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,320 software developers and data experts.

strtol exceptions

Does strtol raise any exceptions?

Thanks!
Jul 22 '05 #1
6 2617
Amadeus W.M. wrote:
Does strtol raise any exceptions?


strtol is a C library function, so it is very unlikely.

--
WW aka Attila
:::
Defeat isn't bitter if you don't swallow it.
Jul 22 '05 #2
Hello Newsgroup

Amadeus W.M. wrote:
Does strtol raise any exceptions?


As White Wolf said, strtol doesn't throw any exception. If you like some
convert method, which throws an exception, i suggest you to use
lexical_cast[1] from boost.

Regards
Stefan

[1] http://www.boost.org/libs/conversion/lexical_cast.htm
Jul 22 '05 #3
> Does strtol raise any exceptions?

It probably throws a null-pointer exception if one of the parameters is
NULL. If it runs out of memory it probably throws some other exception.

Niels Dybdahl
Jul 22 '05 #4
Niels Dybdahl wrote:
Does strtol raise any exceptions?


It probably throws a null-pointer exception if one of the parameters
is NULL. If it runs out of memory it probably throws some other
exception.


It is a C library function. Thereforw it throws no exceptions, since there
are no exceptions in C.

Furtermore there is no "null-pointer exception" in standard C or C++.

In addition - as I can see - strol() does not need to allocate memory, so it
is unlikely that it does.

http://www.dinkumware.com/manuals/re...ib.html#strtol

--
Attila aka WW
Jul 22 '05 #5

"Niels Dybdahl" <nd*@fjern.detteesko-graphics.com> wrote in message news:41*********************@news.dk.uu.net...
Does strtol raise any exceptions?


It probably throws a null-pointer exception if one of the parameters is
NULL. If it runs out of memory it probably throws some other exception.

It throws no C++ exception. There is no such thing as a "null-pointer" exception
in C++ and the bad_alloc exception is not required to be used by strtol.
Jul 22 '05 #6
Niels Dybdahl wrote:
Does strtol raise any exceptions?


It probably throws a null-pointer exception if one of the parameters is
NULL.


You're thinking of Java, which doesn't have pointers but does have a
null pointer exception.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 22 '05 #7

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

Similar topics

1
by: Pavel Krcmar | last post by:
Hi, I'am a little bit confused. I tried this snippet (below) and ( endptr != NULL ) is true everytime. I was looking to http://www.mkssoftware.com/docs/man3/strtol.3.asp and then to...
13
by: Matthias Kluwe | last post by:
Hi! In C, my everyday usage of strtol looked like using char *end; strtol( text, &end, 10 ); to read an int/long and then checking end == ( text + strlen( text ) );
5
by: William Payne | last post by:
Hello, I am in the process of converting a C++ program to a C program. The user of the program is supposed to supply an integer on the command line and in the C++ version of the program I was using...
11
by: nrk | last post by:
Isn't: char s = "--4"; char *endptr; strtol(s, &endptr, 0); supposed to return 0 and set endptr to s? I have run into an implementation (not gcc, gcc does what I expect) that is returning...
10
by: Peter Dunker | last post by:
Hi, I will check a String which should contain a HEX value. I know that strtol is the right function for this job. But what happens when I will check a hex string with 8 bytes? That I can...
3
by: whisper | last post by:
Hello: I am trying to write code to read in a bunch of lines from stdin, each containing a (variable) number of integers and writing each integer in a separate line to stdout. I came up the...
2
by: Marlene Stebbins | last post by:
Suppose I'm using strtol() to convert a command line string to a number and I want to check that the input to strtol() is not non-numeric. strtol() returns zero if input is non-numeric, so I can...
3
by: dstevel | last post by:
The signature for strtol is: strtol( const char*, char**, int) So.. if we start with a passed "const char*" (pointer to const char), then we can't create a non-const char pointer pointer to...
8
by: lovecreatesbea... | last post by:
Does this part of C code call and check strtol() correctly? port = strtol(argv, &endptr, 10); if (argv == endptr){ fprintf(stderr, "%s\n", "Invalid port number form"); return 1; } if (port ==...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.