![]() |
|
|
#144 | |
|
∂2ω=0
Sep 2002
República de California
19×613 Posts |
Quote:
Reading from an uninitialized memory location (in the lingo, a UMR - uninitialized memory read) is clearly nondeterministic - sure, you may get the same result over multiple runs of the program, if those re-use the same memory space and nothing else writes the memloc in question in the interim. (Often when trying to track down a crash or other bug which eventually proves due to a UMR, one in fact relies on that near-term-repeatability aspect over multiple debugger runs). But there's a good reason there are dedicated code tools (e.g. Purify, valgrind) designed to ferret out nasties such as UMRs. Last fiddled with by ewmayer on 2012-02-12 at 20:03 |
|
|
|
|
|
|
#145 | |
|
Oct 2010
101111112 Posts |
Quote:
Last fiddled with by Ralf Recker on 2012-02-12 at 20:28 |
|
|
|
|
|
|
#146 |
|
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
1C3516 Posts |
Code:
while((c = getc(stdin)) != EOF){
if(cp == &in_line[LINELNG-1] || c == '\n'){
/*
stuff to end string*/
}
else
*cp++ = c;
}
Last fiddled with by Dubslow on 2012-02-12 at 22:07 |
|
|
|
|
|
#147 | |
|
Jun 2003
5,087 Posts |
Quote:
Nothing is getting truncated excepted for the printed output!!!! And you know why _that_ is happening.
|
|
|
|
|
|
|
#148 |
|
If I May
"Chris Halsall"
Sep 2002
Barbados
2·67·73 Posts |
|
|
|
|
|
|
#149 |
|
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
3·29·83 Posts |
|
|
|
|
|
|
#150 |
|
Jun 2003
10011110111112 Posts |
|
|
|
|
|
|
#151 |
|
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
3×29×83 Posts |
As for that pointer business, I know understand why what I did was no different from just using standard array notation. As such, I rewrote the LL program, by which I mean I made better use of actual pointers.
http://dubslow.tk/random/ll.txt On the other hand, I think I also went a bit overboard with the pointer arithmetic. One went from one extreme to the other... Edit: I think the old one is faster... Last fiddled with by Dubslow on 2012-02-16 at 03:28 |
|
|
|
|
|
#152 | |
|
Jun 2003
13DF16 Posts |
Quote:
Code:
/* This would definitely be better with indices than pointers. */ |
|
|
|
|
|
|
#153 |
|
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
722110 Posts |
Two typos in one quote. I am a boss.
*Went from one extreme to the other.... *with indices rather than (with) pointers. |
|
|
|
|
|
#154 |
|
Feb 2012
Athens, Greece
47 Posts |
It's also worth noting that there is the D programming language which might be of interest if you want something similar to C++ but with some features of C# and Java. http://en.wikipedia.org/wiki/D_(programming_language)
|
|
|
|