« first day (113 days earlier)      last day (4827 days later) » 

12:00 AM
@72con You follow your project's coding standard. There is no single correct answer.
 
Yes, I'm sure of that. But how do you do it?
 
@72con Personally, I like this style:
if (some_foo_condition
 && some_bar_condition)
 
1 space?
..and the operator at the beginning of the line.
 
I make it so that the condition lines line up
 
Yes. I like how foo and bar line up nicely. It looks better with returns:
 
12:01 AM
uh..
 
return some_foo_condition
    && some_bar_condition;
 
ic
I like that..
 
@72con You wanted to know what I like, right?
 
Yes yes, thanks..
 
@72con You like the return, but not the if? :)
 
12:02 AM
no, I like both.
But I'll have to think about it.
 
Glad you like it.
 
See how I feel about it if I get into using that..
anyways, thanks for your time.
 
@72con No problem, I like chatting about C++.
 
There is a little trick that due to too permissive string constructors also works for strings:
 
As long as we don't start discussing whether it should be T* p; or T *p;... ;)
 
12:04 AM
:D
(I like the former)
 
return 0?0
    : condition1      ? value1
    : condition2      ? value2
    : condition3      ? value3
    :    default_value;
 
@72con So do I, but I also like alias<T*>::type p; (with a suitable definition of alias).
 
one could perhaps call 0?0 the conditional formatting operator ?
 
#define BEAUTIFUL_CODE_FOLLOWS 0?0
 
1 hour ago, by sbi
@fahad: (And my statement was a repeating a joke ISTR @Johannes(?) once made.)
@sbi I think it was @GMan
(the one about -->)
ah yeah, @FredOverflow already found
 
12:13 AM
535 upvotes LOL
What are the most popular questions on SO? Can I sort SO questions based on how many upvotes they got?
 
12:34 AM
@FredOverflow @sbi once directed me to SO database query interface. you can do that there (e.g. i made query for listing unanswered c++ questions). but at least then apparently the database had not been updated for months, it was stale old version.
 
sbi
12:45 AM
@FredOverflow Likely this one:
t͚͓̟̼̳h̼̟̘e̖̭̫̟̮͚̼ ̳<̥̞̰̼c̪e̱̗͍͍͖͖̙n̞͎̲̗͕̦̲t̝͖er̻̤̮̳̥>̱̭̣͕̪ ̭̳̫͔͍̩ͅc͉͕͍an̦͔͈ṋ̜̗o͈̘͇͇͓t̲ h̳̼̺̪o͔͔̤l̜̣͔̰d͇ http://stackoverflow.com/q/1732348
(And, no, your browser is not faulty. Anyway, mine does this, too.)
 
 
2 hours later…
2:47 AM
Suddenly an idea came to mind. I know it's totally off-topic here, but I'd like to know whether you guys think it's a bad idea, or a promising one -- What if SO (or all SE sites) had a "Show your appreciation by making a little donation" button on each answer? Could use a payment system like PayPal. I think monetizing could bring some benefits (for both sides), but I'm not sure about the cons as I haven't put much thought on it yet.
I mean the donation would go to the poster, of course.
 
 
3 hours later…
5:33 AM
Does anybody have anything good to say about either of these books? 1 2
 
6:02 AM
@PigBen 2 is good. Can't say anything about 1.
Its good to be back :-)
 
 
3 hours later…
user379888
9:31 AM
Why does static functions not have this pointer?
 
@fahad because they aren't associated (called) with an object
 
sbi
@PrasoonSaurav Have you been in the penalty box again?
 
9:54 AM
@sbi No I had taken a break from C++ :-)
@sbi Talking about my suspension I paid the price for the mistake I never committed.
 
10:10 AM
morning
 
sbi
10:22 AM
@PrasoonSaurav Taking a break from C++? Why, that's like saying "I had to take a break from having sex all the time"
5
@PrasoonSaurav Tell us!
 
Jan 20 at 16:32, by Alf P. Steinbach
@JohannesSchaublitb According to Prasoon those were his fellow students that he shares a flat (and IP address) with. I tend to believe that, both because I trust him not to do something like that, and because a few votes wouldn't matter to him.
I didn't know sharing IP was banned here.
@sbi I was learning some theory of computation stuffs and mathematics :-)
 
sbi
(Sorry, gotta leave right now.)
 
@PigBen 2 is outdated.
@PrasoonSaurav Ah, primitive recursive functions? The lambda calculus? The turing machine? Good old Big-O?
 
Turing Machine, FSA, Undecidable Problems :-)
 
10:35 AM
@PrasoonSaurav Great, I clicked that link, and now my normal C++ page is also sorted on votes... how do I undo that?
That is, how do I sort by recent activity?
 
Click Newest
 
I should look for the simple solution more often :)
 
@FredOverflow BTW I am stuck on a GCD problem. I need to compute GCDd(2^n-1,3^n-1) where n is very large say n = 1000000. Do you know any efficient method?
 
10:40 AM
Is anything special about the numbers 2^n-1 and 3^n-1 in terms of their factors?
Aside from the obvious fact that 2^n-1 is always odd ;)
Except for the n = 0 case.
Oh, and 3^n-1 is always even for n > 0.
 
No nothing. :-( I know that gcd(2^m-1,2^n-1) = 2^gcd(m,n) -1. Any similar formula as such for this?
 
I don't know of any. Ask mathoverflow.
 
Hmm I hate it, I did like 2 or 3 weeks no C and now my skills are rusty :(
 
@Nils It's not your skills that are rusty, it is the C language ;)
 
10:46 AM
@Nils you're not alone. I suffer of this same problem. Practically everything I stop doing, when I get back at it, I need to revisit various topics over and over in order to reach the status quo ante.
 
Somewhat funny history of programming languages: james-iry.blogspot.com/2009/05/…
> 1972 Dennis Ritchie invents a powerful gun that shoots both forward and backward simultaneously. Not satisfied with the number of deaths and permanent maimings from that invention he invents C and Unix.
> 1980 Alan Kay creates Smalltalk and invents the term "object oriented." When asked what that means he replies, "Smalltalk programs are just objects." When asked what objects are made of he replies, "objects." When asked again he says "look, it's all objects all the way down. Until you reach turtles."
> 1983 Bjarne Stroustrup bolts everything he's ever heard of onto C to create C++. The resulting language is so complex that programs must be sent to the future to be compiled by the Skynet artificial intelligence.
> 1986 Brad Cox and Tom Love create Objective-C, announcing "this language has all the memory safety of C combined with all the blazing speed of Smalltalk." Modern historians suspect the two were dyslexic.
> 1987 Larry Wall falls asleep and hits Larry Wall's forehead on the keyboard. Upon waking Larry Wall decides that the string of characters on Larry Wall's monitor isn't random but an example program in a programming language that God wants His prophet, Larry Wall, to design. Perl is born.
Those are my favorites :-)
> 2003 A drunken Martin Odersky sees a Reese's Peanut Butter Cup ad featuring somebody's peanut butter getting on somebody else's chocolate and has an idea. He creates Scala, a language that unifies constructs from both object oriented and functional languages. This pisses off both groups and each promptly declares jihad.
 
@FredOverflow LOL :D
 
heh
I don't think C was badly designed, it was just designed 40 years ago..
4
 
Reading all this, I wish I liked D a bit more than I dislike it.
 
Gotta go now. See you fellas. :-)
 
10:55 AM
@jweyrich What's not to like about D?
 
@FredOverflow it's so close to C++, but at the same time so different that if I spend enough time on it I fear that I wouldn't be able to write C++ anymore.
 
@jweyrich Because you'd have fortgotten all the important C++ details, or because you'd be disgusted by the idea of returning to C++? ;)
 
@FredOverflow I'd say it's an 80/20, respectively.
 
11:11 AM
@FredOverflow When I was ~9yo, I started learning German, but at the time I was already studying English. Soon my tests revealed various mixed words and such. Was a tremendous mess, so I dropped the German classes. I vaguely remember that.
 
stackoverflow.com/questions/3584705/… I have trouble understanding int(*array)[30] = malloc((sizeof *array) * 10);
so the left side expands to *((*array) + 30), in this case we would have a pointer with double indirection, but what does the + 30 do?
I'm not sure weather I can expand it in that way..
 
@Nils I see no + 30 in the question...
 
I mean can I expand (*array)[30] to *((*array) + 30) on the left side?
 
No. The former is a type, while the latter is not.
I think you need to read up on "the C declarator syntax".
int (*array)[30]; declares array as a pointer to an array of 30 integers.
 
ok
 
11:18 AM
Contrast that to int *array[30]; which declares arrary as an array of 30 pointers to integers. The parenthesis are important, because [] has higher precedence than *.
 
@Nils int (*array)[30] is a pointer to an array of 30 ints.
 
@jweyrich Yeah, I just said that :)
 
@FredOverflow oh I didn't read that sentence. My bad :)
 
@Nils You may want to read this:
12
Q: How do I use arrays in C++?

FredOverflowC++ inherited arrays from C where they are used virtually everywhere. C++ provides abstractions that are easier to use and less error-prone (std::vector<T> since C++98 and std::array<T, n> since C++0x), so the need for arrays does not arise quite as often as it does in C. However, whe...

 
I like this one: "1964 - John Kemeny and Thomas Kurtz create BASIC, an unstructured programming language for non-computer scientists.

1965 - Kemeny and Kurtz go to 1964."
 
11:22 AM
@FredOverflow Thx looks like that's what I need.
 
> 1970 Guy Steele and Gerald Sussman create Scheme. Their work leads to a series of "Lambda the Ultimate" papers culminating in "Lambda the Ultimate Kitchen Utensil." This paper becomes the basis for a long running, but ultimately unsuccessful run of late night infomercials. Lambdas are relegated to relative obscurity until Java makes them popular by not having them.
@CharlesBailey :D
 
In many ways Fortran is more evil than BASIC.
 
@Nils Although a FAQ on the C declarator syntax would probably be more helpful here...
 
You can label lines with arbitrary "line numbers" and "GO TO 4628", which could be anywhere. It could be near line 2.
 
I used to program in basic on the Commodore 64. My first reaction to Pascal on the PC was: "Where are the line numbers? How the heck am I going to do control flow??" :)
 
11:27 AM
@FredOverflow yeah well, what exactly does (sizeof *array) expand to in this question?
 
the size of one element in the array named array
 
I was also amazed by the fact that large line number like 1234 took up more screen space than short line numbers like 10, but the required disk space was equal. (That's because the line numbers were stored in 16-bit binary internally, but I didn't know that at the time.)
 
GOTO was so necessary. Once you'd inserted line 45 between lines 40 and 50, then line 42 between 40 and 45, to save retyping the whole program you could 41: GOTO 380 and at 450, GOTO 42.
 
@DeadMG That is, the size of 30 integers.
 
GOSUB blew my mind.
 
11:28 AM
pretty sure it's just the size of one integer
 
@DeadMG which is ?
 
@CharlesBailey Oh yeah! "How the hell does the computer know where to return to??"
@DeadMG Well, it depends on the declaration :)
 
@Nils: The fuck should I know? You have the code, not me
 
@DeadMG If it's declared as int (*array)[30], then sizeof(*array) is 30*sizeof(int).
 
ok it makes sense now, thx @FredOverflow
 
11:32 AM
@Nils Why don't you simply try it out? The beautiful thing about C is that you can compile and run programs on computers :)
int main()
{
    int (*array)[30];
    printf("%u\n", sizeof(*array));
}
(Does C require return 0; at the end of main?)
 
:) yes that's what I'm doing atm..
 
@FredOverflow in C89, but not in C99. as I recall.
 
@FredOverflow guess so, at least you get a warning if you don't
 
@FredOverflow typo
i don't understand the references everywhere to C14
 
@AlfPSteinbach I don't get it... must be a joke :)
 
11:35 AM
:)
 
C has another upcoming Standard too
C1x
I guess that they just expect C14
 
What are the key feature additions of C1x?
Or is it just a "clarity" release like C++03?
Where would Haskell be without C? ;)
(ghc spits out C at its backend.)
 
what do I care about that either?
 
Would C++ be here w/o C? lol
 
@Nils No, definitely not. We would probably have BCPL++ or Pascal++ (rather unlikely) instead.
 
11:40 AM
@FredOverflow First C++ spitted out C, some current compilers (comeau) still do...
 
@DavidRodríguezdribeas Which is a perfectly reasonable thing to do!
 
Some people thought that C++ wasn't "a real language" because it spat out C. LOL.
 
The only thing I have trouble is thinking about the data arrangement in 2d arrays. If I have an 1d array the data is placed next to each other. If you store 2d data into a 1d array, say in row wise order and then access it in row wise order, caching will work fine, but it will not if you access it in column wise order. But what about 2d arrays?
 
2D arrays are 1D arrays
they just hide it fromyou
 
11:53 AM
@Nils An int matrix[3][3] is laid out in memory exactly like an int matrix[9], that is, 9 integers adjacent in memory. It's just that the type system has enough information at compile time to make indexing a little easier -- you write matrix[y][x] instead of matrix[y*3 + x], but it compiles (more or less) to the same machine code.
 
oh yes
that was the other reason to overload sizeof()
so I could banish primitive arrays forever
 
@Nils: When you deal with multiple nested array types, it might help you to spell it out completely:
typedef int internal_array[10];
typedef internal_array array[20];
Now you can apply your reasoning: "array" places 20 consecutive "internal_arrays" in memory, each of which itself contains 10 ints laid out consecutively.
 
Oh yes, typedef is definitely your friend in C.
 
@FredOverflow It compiles to the same code, but the compile time type information is different, if you have a function that takes an array of 3 ints by reference (or a pointer to such array), then you can pass "matrix[1]" if the array is defined as "matrix[3][3]", but you cannot pass "matrix[3]" is it is defined as "matrix[9]"
I had an argument over bidimensional arrays with a coworker:
int (*p)[3] = (int (*)[3]) malloc( 3 * sizeof *p );
He considered that exactly equivalent to:
int **p = (int**p)malloc( 3*3*sizeof(int) );
And the sad part of it is that I gave up in the discussion... after 20 minutes and a couple of code snippets that proved it, he came up with his own test of compatibility based on C casting (in this case reinterpret casting) from int** to int*:
int **a = (int**) malloc( 3*3*sizeof(int) );
for ( int i = 0; i < 3; ++i ) {
With that as a proof... I just gave up on him.
BTW, has anyone here have to deal with this before (he is not in fact a coworker, but rather my boss, and he is convinced that he is a C++ expert --THE C++ expert in the company for what matters). He has "refactored" some of my code from correct to UB intentionally because he knows what UB does in this case with this compiler... even if the (verified) assembly produced by the compiler is the same, just to make the C++ code "more clear clear"
(More clear meaning: what the * is that "obj->~Type();" doing before "allocator->release( obj );"?
 
12:09 PM
@DavidRodríguezdribeas I have always failed at dealing with suits. Yesterday I posted here YouTube video of 3 Doors Down's music video "Away from the Sun", to illustrate that. But can't be viewed in Germany
i'm going to post link to relevant psychological study from 2000/2001, byt my machine is slow, sorry, may take time
The Dunning–Kruger effect is a cognitive bias in which unskilled people make poor decisions and reach erroneous conclusions, but their incompetence denies them the metacognitive ability to appreciate their mistakes. The unskilled therefore suffer from illusory superiority, rating their ability as above average, much higher than it actually is, while the highly skilled underrate their own abilities, suffering from illusory inferiority. This leads to the situation in which less competent people rate their own ability higher than more competent people. It also explains why actual competence m...
 
The problem is that he is not a suit, but mi direct boss working hands on on technical problems, and worse even, some of the people above believe him as the C++ expert just because he knew more C++ than the rest of the people when he joined 6 years ago. He has probably not learnt much from then on.
 
(It was actually 1999, not 2000/2001, sorry, my memory doesn't work as well as it used to)
 
@AlfPSteinbach Interviewing is a real challenge. It's difficult to separate level incompetence from interview nerves and you can't rely on candidate self-assessment... even if they weren't in a situation that encouraged over-statement.
 
@DavidRodríguezdribeas thx for the idea..
 
12:15 PM
The link is a perfect description, thanks, I now have a name for that... and yet, I do not know how to deal with him (my basic approach has been denial of the problem, just let him talk and ignore what he says)
 
@DavidRodríguezdribeas int** p = ... cannot be the same for the following reason: where would the additional pointers come from? You'd need 9 integers and 3 pointers.
Most bullcrap about 2D arrays vs. arrays of pointers can be debunked with simple diagrams showing nothing but boxes (variables) and arrows (pointers).
 
Yet another question about pointers, std::less and containers: stackoverflow.com/questions/4913161/… .
Personally, I blame @FredO for accepting a misleading answer to his original question ;-) .
 
@CharlesBailey Don't you just love that special language rule about std::less<T>? :)
> For templates greater, less, greater_equal, and less_equal, the specializations for any pointer type yield a total order, even if the built-in operators <, >, <=, >= do not.
@CharlesBailey I did? Oh, I didn't select your answer, I get it :)
 
@FredOverflow I know, but he "proved" it with a test that involved a hidden reinterpret_cast<> (using C-casts). At that point it was either digging into the absurd: yes, you are right, int** is the same as int ()[3], in exactly the same way that void is, here use your own test... or else avoiding greater confrontation... I decided that it was not worth it.
 
@DavidRodríguezdribeas So what did he do, cast an int to an int*? Surely that would have given strange "results"?
@DavidRodríguezdribeas Oh, your expert C++ boss does not even know the difference between destroying an object and releasing its memory? :)
 
12:24 PM
the code, or an approximation of it is above, basically, after you cast the int** into an int* and you do manual arithmetic in the result, they are the same
 
@FredOverflow TBH, I don't care about the points, I just don't understand how the answer you accepted help with the problem that you asked about.
 
@CharlesBailey I found the link interesting.
@DavidRodríguezdribeas Just quit your job and work for Google.
(Or any other company where real C++ skills are appreciated.)
 
@FredOverflow What? And use C++ without exceptions?
 
What I have a harder time dealing with is not that he does not do it correctly but that he takes code that is correct and turns it into undefined behavior just because he does not like the looks of it. One of this cases of "I looked at your code for 10 seconds and now I am going to tell you how wrong you are"
 
@CharlesBailey Okay, maybe Google was not exactly the best example :)
 
12:26 PM
right
 
let's see how effective this gaviscon stuff is
 
0
Q: “Uninitialized use” warning in the g++ compiler

Konrad RudolphI’m using g++ with warning level -Wall -Wextra and treating warnings as errors (-Werror). Now I’m sometimes getting an error “variable may be used uninitialized in this function”. By “sometimes” I mean that I have two independent compilation units that both include the same header file. One com...

a riddle for you riddlers
 
freeimagehosting.net/image.php?ba307233ee.png This picture illustrates it nicely I think..
afk lunch
 
0
Q: iterate std::vector<std::vector<char> >?

TonyI have a vector like this: std::vector<std::vector<char> > _lines; I would like to iterate these vector and the vector contained within, however I'm not sure how I'd access the inside vector using the iterator of the first one? I have the following already: std::vector<std::ve...

 
12:30 PM
@Konrad: You could be seeing global variable shadowing
 
@KonradRudolph since difference with two different headers, have you considered evil macros? anyway, just don't use -Wextra.
 
@DeadMG But even if, this would still always refer to the same variable (local)
but no, there’s no global variable that I’m shadowing
 
yes, but you could be confusing the compiler
that's pretty much all I got
or, of course, evil macroage going on
otherwise, there would be no reason for the warning to only appear once of the two translation units
 
@Alf But I want to use -Wextra … as I mentioned in the question, this particular warning has already saved my ass
and I’ve grepped the whole codebase, no (!) other occurrences of the identifier cmpres
 
@Tony Prepare for a wave of answers :)
 
12:32 PM
@FredOverflow I'm prepared, I think?!
It's probably a n00b question, but I've never had to do it before...
 
@KonradRudolph Just follow @FredOverflow advice. The cost of the extra initialization is probably negligible, unless that is used inside a very tight loop.
 
@KonradRudolph #define and & // super-optimization he he
 
@David The problem isn’t additional cost – the problem is that this would just be hiding the actual error, in case that value is ever read
@Alf no, no define. That’s standard C++
 
@Konrad: You could use a run-time class for it
 
@KonradRudolph perhaps you should just include the ios646 header or whatever it was called, to make sure
 
12:35 PM
class ... {
    bool initialized;
    T value;
public:
    operator T&() { assert(initialized); return t; }
};
you get the drift
 
@KonradRudolph yes, "and" is standard c++, but we're talking real compiler here.
 
@DeadMG good idea
 
@Tony Hm, only five answers thus far... I'm a little disappointed :)
 
@Aldf “real compiler”?
 
@FredOverflow haha :) that's funny
 
12:37 PM
You should ask whether T* p; or T *p; is better, I guarantee 10 answers within five minutes ;)
 
@KonradRudolph yes. both msvc and g++ implement "and" keyword as macros. with msvc that's openly done, you have to include the iso646 (whatever name) header to use em. with g++ it's only indicrectly visible, like in error messages.
 
@FredOverflow I don't really need to know that, although I guess that would come down to personal preference
 
@FredOverflow What's wrong with T * p; ? It's always good to add a comment to throw people off. T * p; // multiply - discard result .
2
 
@KonradRudolph It may be that simply by writing "&&" instead of "and", warning will disappear.
 
@Alf Ah, that’s what you meant. I’ll try it
(but since and is defined to be equivalent to &&, not & I doubt it)
 
12:39 PM
@CharlesBailey I like T*p; even better, no superfluous whitespace ;)
 
@KonradRudolph, I was thinking on whether it made sense to refactor the loops, after all, the scope of the cmpres variable is to each of the loops, and not the overall block. This might or not help you get away from the compiler warning, but if needed further refactoring might help there, if you have enough interest in not initializing the variable
 
@David How would you refactor this – apart from putting braces around each loop and having a block-local copy of cmpres in each (unfortunately, this merely results in two warnings instead of one)?
@Alf: for the record, replacing and with && didn’t help.
 
for ( int cmpres; b <= c && (cmpres = cmp(b, pivot) <= 0; ++b )

or

while ( b <= c ) {
int cmpres = cmp( b, pivot );
if ( cmpres > 0 ) break; ...
The second one is probably more readable
 
I wonder where the integer mult comes from in shark
does a[i][j] expand to a multiplication?
 
@Konrad: Why are you implementing Quicksort (?), if I may ask?
 
12:45 PM
@Fred it’s a parallel implementation
well spotted, by the way ;)
 
@Nils You can think of it that way, yes.
 
I don't think you will get warnings on the second case, other stranger syntaxes:

while ( b <= c ) {
if ( int cmpres = cmp(b,pivot) ) {
if ( cmpres > 0 ) break;
} else {
::std::iter_swap( a++, b );
}
++b;
}
But this one is probably harder to understand/follow
 
@David Hmm, declarations in if conditional aren’t allowed
 
@KonradRudolph I have two courses where I have to peek over dozens of students' shoulders who fail at implementing Quicksort. Now I can recognize a Quicksort algorithm within 2 seconds ;)
 
but I’m currently implementing your second idea
 
12:47 PM
@KonradRudolph Just try :)
 
@KonradRudolph Pretty sure they are allowed.
For example, if (Student* student = dynamic_cast<Student*>(person)) { ... } is a common C++ idiom.
 
@David @Fred duh, yes. But your conditional isn’t enough, it needs to be if ((int cmpres=cmp(b, pivot)) >= 0) and that isn’t allowed
 
@KonradRudolph My conditional? :)
 
@Fred David’s
 
uh, Konrad
 
12:50 PM
LOL
 
what test, exactly, do you think is performed when you pass an int to if?
 
@DeadMG != 0, not >= 0
 
That is why I reworked the conditions, the if only tests for != 0, and then a second if in the if branch tests for > 0 (as compared to <0)
 
oh yeah
:P
 
Anyway, that is the reason for the comment at the end: probably harder to understand/follow
 
12:50 PM
@David Oh I see. That’s nasty :p
 
humm last question.. so a[i][j] expands to *(*(a + i) + j).. but I don't see how the compiler replaces this with a multiplication
 
@KonradRudolph it is
 
no it doesn't @Nils
 
it does, let me send the complete picture, @DeadMG
 
@Nils the scaling factor for inner "+" depends on the type of a.
 
12:52 PM
else a[1][1] == a[2]
but that doesn't take into account the size of the first dimension
so it's clearly flawed
 
@AlfPSteinbach yes, well gcc replaces it with a multiplication
 
@Nils Because a + i involves pointer arithmetic, and that depends on the size of the element type, which in turn is influenced by the second dimension.
 
The compiler knows that the element type of a is int[30], so when you say a[i], it has to add 30*i to a on the machine level. Got it?
 
yes
 
12:55 PM
can a '\r\n' be represented in a char array and then actually print to the console if that array is output to the console?
 
if n is the size of the a square 2d array it would maybe hold [i][j] == *(a + j*n +i), let me try this out..
 
@Tony Yes, but why?
 
no, cause there's no NULL
which the console output function will expect
you'd have to output each character manually
 
@Nils Are you writing C or C++ code?
 
C
is it different in c++?
 
12:57 PM
Ah pity the foo
 
@CharlesBailey I need to print a square on a console screen using - and | and of course I need to take a new line in this process, so I thought I'd represent my screen as a 2D array of chars and stick all char's in there, then print the array to screen
but the output in the array is different to the result on the screen
and I have a feeling my '\r\n' aren't being printed
 
@Tony On any conforming implementation \n will be translated to the correct newline sequence so you shouldn't have to worry about \r.
 
you need \n
 
@Nils In C++ (and with a modern compiler), I would strongly recommend writing std::array<T, n> a; instead of T a[n]; because all the nasty implicit conversions disappear. int a[10][20]; would become std::array<std::array<int, 20>, 10> a;. (On a less modern compiler, you could still use boost::array.)
 
If I want to replace a[20][10] with a mul, where do I dereference the second time?
 
12:59 PM
also, '\r\n' is invalid
as it is not a single character, it is two
there is no second dereference
 

« first day (113 days earlier)      last day (4827 days later) »