« first day (688 days earlier)      last day (4243 days later) » 

12:05 AM
just a quickie, Why when writing to binary files people do this fbin.write(name, sizeof(name) - 1);
assuming name is a char array
why do they do 'sizeof(name)-1'; wont just 'sizeof(name)' work?
 
@MohamedAhmedNabil Maybe they don't want to write the trailing \0.
 
@EtiennedeMartel Will it matter? when its read back doesnt the \0 get added anyway?
 
@MohamedAhmedNabil Depends on how it's read.
 
if i do this fbin.write(name, sizeof(name) - 1)
then this fbin.read(name, sizeof(name) - 1)
wont \0 get read anyways?
 
You'll read sizeof(name) - 1 characters.
 
12:10 AM
fbin.write(name, sizeof(name) - 1) if name is 20bytes then 19 bytes are written right?
 
12:25 AM
what is C++ error C1075
 
@MohamedAhmedNabil There's generally a message right next to it that tells you what's wrong.
 
end of file found before the left brace
and the line is line 1 O.o
 
Then there's probably some mismatched braces in your code.
 
meaning?
i pressed Ctrl Z and i redoed all my changes that i did since i opened the file and the problem is still there
 
It means that a brace is missing.
 
12:29 AM
/this error always randomly appears, it gets annoying
 
It's never random.
 
but the line is 1
 
Show the code.
 
12:46 AM
i waas away sorry
one sec
@EtiennedeMartel ideone.com/z5yDk
 
@MohamedAhmedNabil That compiles.
 
@EtiennedeMartel OMG i knew what was wrong XD You wont stop laughing XD
instead of opening a project i just opened main.cpp in another non completed project XD
 
Told you it wasn't random.
 
im a fool XD
@EtiennedeMartel How do you think of my coding format, style and arragment?
 
@MohamedAhmedNabil It's fine.
 
1:07 AM
Don't use using namespace std
 
@Rapptz It's fine in a .cpp file.
 
@EtiennedeMartel It's good to break the habit early though.
 
Xeo
1:27 AM
@R.MartinhoFernandes ^^
 
 
2 hours later…
3:20 AM
When i send a string to a text file, is the null char dropped?
 
Why don't you try it and see for yourself?
 
@MohamedAhmedNabil a real string conceptually doesn't even have a nul at the end. if there's one in the content of the string, yeah, it should be written to the file
as for a c string, that depends on whether you specify the length and the length includes the nul terminator
 
ofstream obj("file.txt");
obj<<"hello world";
@cHao I dont see any nulls written to the file
 
@MohamedAhmedNabil Good, you just answered your own question. :)
 
@MohamedAhmedNabil i don't see a \0 in that content, so :)
 
3:25 AM
@Mysticial I was checking if they the null is dropped or just not seen in the file
@cHao obj<<"hello world"; This is a string literal, which is a char array which is null terminated.
 
@StackedCrooked Hey you, check this out.
 
Zero termination is an implementation detail.
 
@cHao Even when i do this obj<<"hello world\0"; there is no nul in the file
 
Most editors will display a box character or something.
You can also check the size of the file and see if it adds up.
 
@EtiennedeMartel Alright.
 
3:27 AM
@MohamedAhmedNabil Open it in a hex editor, I'm pretty sure there's one.
 
@MohamedAhmedNabil of course there isn't. c strings are nul terminated, so when you output one without specifying a length, the output stops at the first nul
 
@cHao ooooooooooooh
 
@cHao Oh, right, forgot about that.
 
@cHao How do i determine size when outputing to a text file XD?
 
@MohamedAhmedNabil That, my friend, is a common problem with serialization.
 
3:29 AM
@MohamedAhmedNabil with a c string? you don't, really. you trust that the string is nul terminated, cause that's what makes c strings work. if you don't keep track of the length, you can't trust it to be correct
 
How do you specify lengths?
 
@EtiennedeMartel fwrite() with wb+
 
I'm lost.
 
Not sure what the preferred C++ way is...
 
std::strings know their length, so anything in them will be output
 
3:30 AM
@cHao Yeah, but when you read it back in?
 
easiest way i know of would be to write out the length of the string right before the string itself
then when you read it in, read the length, read that many bytes into a buffer, and make a std::string out of it :)
 
Yep, that's what I would do. I never was a fan of terminated strings.
Even works with raw binary blobs!
 
Didn't you have a question similar to this before?
 
This guy always comes up with the same questions.
I admire his desire to learn, but sometimes I feel like he's not actually listening.
 
If you are talking about me, i never asked this before.
I guess something like this should be moved to the main website not the chat, it isnt a small question
 
3:36 AM
@EtiennedeMartel Is this the same Mohamed? It's a very common name.
 
@Mysticial I think so.
 
He's the only Mohammed I see in chat.
 
btw i only asked a question twice once. :D
 
You bastard!
 
I vaguely remember several questions about streams.. binary.. null terminator.. objects.
 
3:37 AM
It's a null fetish.
 
@Rapptz but never the same question twice
 
They're similar :P
 
But they arent ==
 
What are you asking btw
If C++ strings are null terminated?
 
@Rapptz I believe they are, otherwise string::c_str() wouldn't work the way it does.
 
3:40 AM
@Rapptz if the null gets stored when sending a c-string to a text file, The question suddenly divided itself to 50 subcategories so i just shuttep up and mentally thought "I should ask this on stackoverflow.com instead"
 
@MohamedAhmedNabil Wait.. you mean if the \0 is written into the text file?
 
@Rapptz nop
 
Why does it matter if the null is stored or not
 
@Rapptz I like to know the details ^.^
 
@MohamedAhmedNabil Maybe read this
or google around.
 
4:19 AM
Morning
 
4:53 AM
Best title of the day:
-1
Q: i learning java i want line between 2 data in o/p

android fresherOutput of below code i must get in this way:- "Bruce", |"ADAMS", |"bruce.adams@bluewin.ch",|,"1657",|"883",|"Resident Renewal",|"Active",|"2011-05-10",|,"2012-01-01",|"2012-12-31",|"Canada", | | | | | | | | ...

 
"I learning". Yeah.
 
I am new to java can u give me code plz..thank u — android fresher 31 secs ago
2
 
5:20 AM
lmao
 
6:05 AM
@Mysticial there's a reason you have to call c_str() to get a decent C string. afaik there's nothing requiring that a c++ string's underlying array have a nul at the end in general, so at the very least, c_str() has to ensure that one is there
if you just use &str[0], you're taking your chances
 
@cHao Well, c_str() returns a const char* so the caller doesn't "own" the pointer. In other words, it needs to be stored inside std::string itself. Furthermore, std::string:c_str() is const. So it's not like it can append the nul on the fly.
So by process of elimination, I see no other way to implement `c_str()`.
`std:string` has to have a full nul-terminated cstring as its internal representation.
 
are my privileges bugged. hm
 
@Rapptz ?
 
Ever since the vote down privilege I haven't gotten any others.
 
@Rapptz IIRC, you don't always get notified. I remember the 5k and 15k privileges being skipped. No notification, but I gained the privilege.
 
6:13 AM
@Mysticial Well.. it says I need 250 rep to view close votes but I can never seem to see them.
 
@Rapptz Oh, only on your own question.
 
looks like gcc's implementation might zero out the memory...which makes sense, if it's basically going to construct each element of the array as well
 
@cHao for what context?
std::string?
 
@Mysticial oh
 
@Mysticial Is there something saying the buffer can't be mutable? Not saying that's how it is done, just thinking out loud about whether it would be possible.
 
6:15 AM
I've also seen a 1k user cast a reopen vote on his own question.
@JerryCoffin c_str() is const. So it's not allowed to change anything in the std::string object.
 
I don't ask questions here.
 
@Mysticial The whole point of mutable is that it means a const member function can still modify it.
 
@JerryCoffin I've never thought of that. :) But I can imagine the concurrency problems it could run into.
If the user expects a const methods to not modify the object.
Not sure what the standard says about this...
 
considering the function isn't modifying anything that actually represents the object...
 
Does the standard say anything about the complexity of c_str()?
 
6:21 AM
lemme check
 
Not that it matters anyway, since appending a nul is O(1).
 
@Mysticial In C++03, nothing -- doesn't mention concurrency at all. In C++11, I'd have to do some looking to be sure.
 
Interesting the Simplex method was invented way before Quicksort. "Top 10 algorithm of the 20th century" http://www.uta.edu/faculty/rcli/TopTen/topten.pdf #cs
That is a nice monday morning reading IMHO :)
 
27.1.4.1 (3): "Requires: The program shall not alter any of the values stored in the character array."
oh, wait
the program, not the class
 
@Mysticial c_str() is required to have constant complexity. It does mean one thing: even if the string doesn't currently have a NUL terminator appended, it needs to always leave space for one, so it can be done in constant time if needed. If the space wasn't there, it could have to allocate a buffer and copy the current content to the new buffer, which would be linear complexity.
 
6:25 AM
right...so it could always allocate space for an extra char
and just not bother to put a 0 at the end til c_str() or data() was called
 
@cHao Exactly. The fact that c_str is also noexcept forces the same thing, since allocating a larger buffer could also throw (granted, c_str could catch the exception of the allocation failed, but if the allocation failed, c_str() couldn't succeed and has no way to signal failure).
 
So barring mutable, then yes, std::string is guaranteed to have a nul-terminated c-string inside it.
If mutable is used, it might imply the use of locks to keep it thread-safe depending on whether the C++11 standard guarantees that c_str() thread-safe with all other const functions in std::string.
 
a std::string is likely to have a c-string inside it. but there are enough ifs and gotchas that it'd probably be a bad idea to assume it does
just call c_str(), and you don't have to worry about it :)
 
@sehe What?
 
@cHao Given all these requirements, it wouldn't be sensible for std::string to not have a c-string inside it.
Actually... Does C++11 guarantee thread-safety of concurrent calls to const functions on the same object?
 
6:43 AM
Is anyone here using some linux operating system? Like ubuntu?
 
What do you need to know?
 
@Mysticial not that i'm seeing...but i just skimmed over it
 
I'm not sure where to put Sublime text, I have a binary and its folders, so I can run it locally in a folder. But I would like to put it where all other programs are, like in the bin folder. I'm not sure what to do with the extra folders though
 
$(HOME)/bin
?
/usr/local bin is also common for custom installed stuff
 
There are no other help folders in there for other programs. I though maybe they are located somewhere else
 
6:47 AM
@Mysticial it would be sensible enough...you merely have to allocate enough memory for an extra char. i'm not seeing anything yet that says you have to zero it out. and if you're gonna be working with strings a lot, it doesn't make a lot of sense to keep zeroing out elements that a caller messing with std::strings shouldn't even assume exist
 
@cHao I'd assume that appending the nul at the end of each operation is negligible in performance.
 
@Mysticial except that if you're appending chars onto a string one by one, you've just potentially doubled the time it takes to do so
 
@cHao Not really. When you're appending chars one-by-one, it'll be dominated by overhead costs anyway.
1. You have a function call. (maybe not if it's inlined)
2. You have to increment the length variable.
3. You have to check if you need to reallocate.
4. You have to actually append the character.
oh no... not again...
0
Q: Is tr any Possible of geting output in this way in java..if u knw plz help me

fresher Is tr any option to do above image output in java.. I want d Output in this way. can any one guide me.. above there is a code... In middle i need line that separate the Output data. thanks in advance..

same OP
 
fresher quality
he added code
 
The title is still awesome.
 
6:54 AM
I fixed his formatting
How much rep until my edits aren't peer reviewed?
 
@Rapptz How did you do it so quickly?
 
Notepad++ plugin
 
ah...
 
@Rapptz 2k, i think? the privileges list should show you
yeah...2k
 
mhm
long ways to go.
 
6:59 AM
You gained a lot of rep these last few days. Keep that up for a few weeks and you'll have it.
 
@Mysticial if you're interested in that plugin, I found it for Sublime Text.
 
I've never even heard of Sublime Text, lol
 
That OP should be question banned now. I can't tell for sure, but a -4 and -6 is probably enough given that he doesn't have enough good questions.
 
lol I just realised that guy's code had absolutely nothing to do with his problem.
 
7:10 AM
I didn't even bother to look.
 
-3
Q: how do i get the Analytical Badge here in StackOverflow?

rubo77It sais: "Visited every section of the FAQ" on http://stackoverflow.com/badges I read the whole FAQ thoroughly now, but I didn't get that Badge still ;)

 
Shit... I still don't have that badge...
 
@Rapptz Have you tried it?
 
@StackedCrooked Yeah, it's pretty neat. I also get up gcc with it.
 
I'm sleepy as fuck.
Maybe cookies will help.
 
7:21 AM
hm.. now I'm hungry but it's 3:21 AM.
 
@StackedCrooked Hi sleepy as fuck. How are you today? And how did you get on StackedCrooked's computer?
@StackedCrooked Cookies always help. Most web sites seem to agree...
 
I'm sleepy stackedcrooked as fuck.
 
@StackedCrooked's account must have been compromised. Two other people (sleepy as fuck and sleepy stackedcrooked as fuck) are using it.
 
I'm amused.
 
@Mysticial We should probably report it immediately. It's almost as bad as the night that "God I'm drunk" started posting to Usenet under my name!
 
7:26 AM
@StackedCrooked or sleep.. just saying..
 
What's sleep?
 
I'm at work. It 9:30 AM.
I've slept over 16hrs.
 
that's too much then
 
I'm slowly waking up.
 
morning all!
 
7:31 AM
I wonder when I slept like 16h last time..
..maybe when I was recovering from drinking waayy too much. But this was a long time ago :)
 
people on you tube seems to have confused "spam" with "I don't agree"
 
I don't agree with spam.
 
but not everything you disagree with is spam
 
@StackedCrooked Eat much of it, and Spam won't agree with you either.
 
@JerryCoffin eat any amount of it and it won't agree with you :P
 
7:35 AM
Naturally, nobody wants to be eaten.
 
you're Spam?
 
It seems I'm not entirely awake yet.
 
I'm not Spam, but I am pretty sleepy too. Fortunately for me, it's 1:30 AM, so I don't have to struggle with trying to stay awake at work -- I'm going to go get some sleep.
 
looks to me like nobody cares :(
 
@JerryCoffin Sleep? Nice! Good night then.
 
8:01 AM
@Nils As long as it builds on their build servers they probably won't consider it a serious issue.
 
Well the problem is with the bundled zlib
I now try with the windows zlib, let's see.
Also does a VS project dll project always generate a lib file? Or are there case where /implib is ignored?
 
You can find the solution by Googling for "open_file_func" : undeclared identifier.
 
ouh crap forgot to google lol
thx @StackedCrooked
 
That's my default approach. Find the first compiler error and Google it.
 
Use VS 2010?! That is not a solution.
 
8:07 AM
Seems like you're out of luck then :P
 
Well I try with the sys zlib now, but I thought VS 11 is supported with Qt5.
Maybe they are still on 10 and do not care that much about Windows..
unless u buy a commercial license or something :P
 
8:38 AM
@Collin Genius. Had me rotfl. The "and that dude in New Jersey" part did it
 
0
A: What does it mean to be the left operand?

FredOverflowThree points: Passing the parameter(s) by value is expensive, because all the data members have to be copied. Since the comparison does not alter the objects, you should sprinkle const on your code. if (expr) return true; else return false; can always be simplified to return expr; Modified co...

 
room topic changed to Lounge<C++>: It's bacon week! [c++] [c++11] [c++-faq] [mooning-ducks]
@Nils chat.stackoverflow.com/transcript/message/4800846#4800846 you were the one that kept going on about so-called 'fucking hours'? I just thought it sounded an ok thing to have
 
9:03 AM
What's bacon week?
 
9:17 AM
MODULES!
 
@sehe The SC2 upgrade that was weeks ago.
 
@FredOverflow oooh
 
@FredOverflow Yeah :)
 
@LuchianGrigore It's what happens when bacon day continues going
 
Will have to watch this when I have time.
 
9:19 AM
^ starboard-ready link, lol YouTube misspelled his name, fixed
> i learning java i want line between 2 data in o/p
@Mysticial lol what is o/p
 
Xeo
@FredOverflow I thought I linked that one already?
 
Ah. It'll be fun for loungers who'd already forgotten they've seen it before :)
 
@Xeo When and where?
 
Xeo
@FredOverflow yesteday or the day before, when I found the Boostcon videos on youtube
 
ugh, will have to watch it when I get home. Can't hear anything with the earbuds I use at work
what are the highlights?
 
Xeo
9:27 AM
The audio quality is rather bad on most of the Boostcon vids
@jalf How modules are going to look, what ClangModules look like now, advantages, how they work, etc
 
I have a very strong urge to saddle a pig and ride around work
 
Xeo
And the history of how he came to write the proposal
@thecoshman Play Minecraft at work!
 
@Xeo but I want to do it for real!
 
Xeo
btw :)
 
you've hit a new low.
Some psychologists have indicated that monday is the best day to freak out. I think we're seeing this corroborated
 
9:31 AM
Hi.
 
Xeo
Oh hey robot, saw my ping?
 
@sehe ¬_¬ hardly
 
@Xeo It's rude to call people by their ethic background.
 
Xeo
@StackedCrooked Shaddup, pirate. :P
 
@Xeo Yes. I'll download it and watch later.
 
Xeo
9:33 AM
Or should I call you gummybear?
 
@StackedCrooked Robot is not an ethic background.
 
That's what you think
 
Xeo
wtf
 
@R.MartinhoFernandes Not yet..
 
Why would it ever be.
 
9:35 AM
To annoy you
 
Ethics have nothing to do with being a machine or a meatbag.
Pirate can be considered an ethic background, though.
 
Ethnics - god, how'd I miss that
 
@R.MartinhoFernandes Ethics != Ethnic
 
@thecoshman So what?
 
@thecoshman That statement holds true in either case
 
9:38 AM
Ergo, if Robots where to become sentient, other then your fine self of course, robot can be considered an ethnic background
 
@thecoshman The first time ethnicity was mentioned was after the message you replied to.
 
Cut the pirate some slack. He's seriously incapable of spelling, and probably riding a saddled pig through the office right now
2
 
@R.MartinhoFernandes ¬_¬ I have terrible terrible reading
 
Pro tip: don't go to see psychics. No more readings
 
@sehe one day, I will live the dream
 
9:41 AM
Of spelling correctly?
 
We don't really want to know, right
 
@StackedCrooked meh, spelling. I just want to ride that pig... literally, and maybe figuratively...
 
sbi
@thecoshman If you want to ride a pig around the office, at least be a man and ride it unsaddled.
Riding saddled pigs is pathetic.
 
@sbi you raise the bar...
 
@sbi It was a game reference.
 
sbi
9:48 AM
@thecoshman If it's always the job of the others to raise the bar, then you're not ambitious enough.
@R.MartinhoFernandes Oh, was it? Well, I'm game if you are.
 
@sbi I was envisioning spending the day atop my saddled pig, working when ever it feel like standing near my desk... but maybe... if I mount a mobile desk to the pig, I would be (technically) doing nothing wrong
I very much doubt there is a president for riding a pig at work...
 
@thecoshman Can you even bring animals to work?
@thecoshman Why would there be a president of riding pigs at work?
Who would elect him?
 
0
A: How can I tell what the default parameters are for CvSVMParams in opencv?

Cheers and hth. - Alfwell, since opencv is open source you could just look at the source code but it's often faster to just google it, like https://www.google.no/search?q=struct+CvSVMParams then right click on third hit, end up at the opencv documentation http://docs.opencv.org/modules/ml/doc/support_vector_machine...

 
@R.MartinhoFernandes I'm not sure if it is explicitly forbidden
@R.MartinhoFernandes did I spelling it wrong? erm... there is not a previous case of some one doing it
 
Oh.
Precedent.
I was honestly confused there.
 
9:53 AM
yeah, that's the word :P
 
sbi
@thecoshman dictionary.com
@R.MartinhoFernandes He works in Ireland. (Must I say more?)
 
@sbi dictionaries are not the helpful when you are correctly spelling the wrong word
 
^ I think i showed great restraint in answering this zillionth'+1 RTFM question
 
sbi
@thecoshman "a person who presides."
 
well no, they're useful for checking that the correctly spelt word means what you think it means
 
9:56 AM
Spelt, also known as dinkel wheat, or hulled wheat, is a hexaploid species of wheat. Spelt was an important staple in parts of Europe from the Bronze Age to medieval times; it now survives as a relict crop in Central Europe and northern Spain and has found a new market as a health food. Spelt is sometimes considered a subspecies of the closely related species common wheat (T. aestivum), in which case its botanical name is considered to be Triticum aestivum subsp. spelta. Evolution Spelt has a complex history. It is a wheat species known from genetic evidence to have originated as a hy...
 
@TheForestAndtheTrees spelt is a plant substance, spelled is the past tense of spelling a word
 
anyway, thunderbird now has nicer-looking tabs than firefox
 
Is this a place to ask q about c++?
 
only if it pertains to thunderbird and firefox
 

« first day (688 days earlier)      last day (4243 days later) »