« first day (198 days earlier)      last day (2661 days later) » 

2:59 AM
void* pVoid = static_cast<void*>(&buf[0]);
What's the point of casting something to <void*>
 
3:12 AM
hi
 
user406009
@Datsik There is no point. It should happen anyways. Probably just to clarify some api usage.
 
user406009
(There are some APIs which take void* as input and whatnot)
 
user406009
@Steephen Hello. Welcome to this room. Let us know if you have any questions.
 
user406009
(Which may or not be C++ related)
 
Thank you @Lalaland!!
Definitely will ask if I have anyone
 
user406009
3:21 AM
@Datsik Oh, and the reason why APIs use void* is that every pointer can be cast safely to void*
 
3:54 AM
@Lalaland Thanks, one last question in this
typedef struct AuthHandler
{
    eAuthCmd cmd;
    uint32 status;
    bool (AuthSocket::*handler)(void);
} AuthHandler;
What exactly is bool (AuthSocket::*handler)(void);
I know it s a function that returns a bool but I don't know exactly what (AuthSocket::*handler)(void); is doing
 
user406009
I believe that's a method function pointer.
 
user406009
Yup, just double checked the syntax, that is a method function pointer.
 
user406009
bool (AuthSocket::*handler)(void); is just declaring that there is a method function pointer with the name handler.
 
user406009
The syntax for function pointers in C++ is really, really messed up.
 
user406009
handler is the name of the variable.
 
user406009
4:03 AM
@Datsik stackoverflow.com/questions/1485983/… has a decent guide on how they work.
 
user406009
I guess it might also be called a "pointer to member function"
 
user406009
Also, I highly recommend using a typedef whenever you use function pointers in C++.
 
user406009
They make the syntax much more sane.
 
user406009
typedef bool (AuthSocket::*AuthSocketHandler)(void);

typedef struct AuthHandler
{
    eAuthCmd cmd;
    uint32 status;
    AuthSocketHandler handler;
} AuthHandler;
 
user406009
(Of course that might not be your code, but whenever you feel the need to use a function pointer that's what I would recommend)
 
5:58 AM
When it comes to something like this uint8 securityFlags = 0x01;
and the flags can range from 0x01 - 0x04 how do I add more than 1 flag to the securityFlags?
 
 
2 hours later…
8:11 AM
@Datsik punch the person who hasn't provided symbolic constants for individual flags first
and when the person finally does this and provides constants const uint8 firstFlag = 0x01; const uint8 secondFlag = 0x02; const uint8 thirdFlag = 0x04;, then you can simply use uint8 securityFlags = firstFlag | thirdFlag;
 
 
1 hour later…
user2015064
9:45 AM
I have trouble trying to read this file in C++.
 
user2015064
Rose Sakory
16
Student
Part-time worker
Blogger
--------------------------
Maria Cadanario
34
Teacher
Customer service
-------------------------
Susey John
32
Worker
 
user2015064
First is name, second is age, third is occupation which can be unlimited.
 
user2015064
People can also use a number of delimiters (-). My only problem is how to bypass these delimiters to read the next entry.
 
user2015064
Do you guys have any idea?
 
9:47 AM
1 min ago, by Griwes
Stack Overflow
 
user2015064
I don't have any real problem yet, so stackoverflow may not be a good idea. I want some direction.
 
user2015064
"People can also use a number of delimiters (-). My only problem is how to bypass (ignore) these delimiters to read the next entry."
 
@xersi What do you mean by "unlimited?"
@xersi You need to use a context-sensitive language. Define the grammar, and then the non-terminal rules, and then parse
 

C++ Questions and Answers

Solve problems and approach solutions. Just ask and lurkers wi...
 
Ven
someone give griwes owner!
oh wait....
 
user2015064
9:51 AM
I will post there, so please help me.
 
user2015064
A person can have a number of jobs and want them to be all stored in a vector.
 
user2015064
Rose Sakory
16
Student
Part-time worker
Blogger
--------------------------
Maria Cadanario
34
Teacher
Customer service
-------------------------
Susey John
32
Worker
First is name, second is age, third is occupation which can be unlimited.
 
15 messages moved from Lounge<C++>
 
@xersi Like I said
you need a context-sensitive language and a grammar that specifically defines it
 
user2015064
What I don't know is while reading the jobs, I have to manage to catch '-' at the same time so that I can ignore a line of hypens. Do you guys have any idea?
 
9:53 AM
Most parsers are written for that
@xersi Context-sensitive languages and parser
 
can still be regular
 
@xersi read the file line by line, store the lines in a vector of strings, count the lines, reset the counter when you encounter the line of -s
@VermillionAzure unbounded number of occupations
 
user2015064
So you mean I continue to use getline and check the first character if it is a hypen?
 
@milleniumbug Yes. That is possible with a context-free grammar.
 
user2015064
Okay, this seems to work. getline solves everything. I just forget that!
 
10:00 AM
@VermillionAzure it's also inapplicable here because I'm 99% sure @xersi attends a basic programming course
 
@milleniumbug Oh boy.
@milleniumbug In reality, it really is a parsing problem.
@milleniumbug So it's still the right answer I suppose. He just needs to take the basic ideas he needs
 
nobody cares
 
@VermillionAzure that is also possible with just a DFA
 
compiler course is taught later, not in freshmen year
 
@ratchetfreak I guess so.
@ratchetfreak None of the recursion stuff with stacks is going on
@milleniumbug I mean, the idea of languages don't have to be too hard i guess
 
10:08 AM
@VermillionAzure you're throwing language theory at a person who struggles with basic programming course
the fact they ask this question in the first place suggests your answer is inappropriate for their skill level
 
@milleniumbug you're right
 
 
2 hours later…
12:27 PM
int x = 1;
int f(int y)
{
return x ;
}

int main() {
int x=2;
printf("%d", f(0));
}
what should this print
?
 
what do you think it should print
 
12:48 PM
1
 
and it does
 
what i do not understand is the dynamic and static scopic
what does it mean for c
6
A: static scoping in C/C++

nwpIt does take the nearest x, but since you only have one x it doesn't really matter. If you change the code to int x = 1; int f(int y) { return x ; } int main() { int x=2; printf("%d", f(0)); } so you have 2 x, the global one and the local one in main you will see 1 get...

this question
i am unable to understand dynamic and static scoping ,never heard of that word
 
there's lexical scope and dynamic scope
if C was dynamically scoped, your f would return 2 because it would access local variable of main, by looking up the call stack
but it's not, it's lexically scoped, so x refers to the global variable because there's no declaration in the lexical scope of f (i.e. no declaration in source code)
I think wikipedia page explains it better than I do: en.m.wikipedia.org/wiki/…
 
user406009
1:24 PM
Very few languages are dynamically scoped nowadays.
 
user406009
I think Lisp used to be, but nothing else.
 
Ven
depends which lisp
the old "LISP" was. Elisp still is, but has a directive to go lexical. Common Lisp has both, but no top-level lexical bindings. Clojure has :^dynamic. Scheme/Racket has parameters.
 
 
3 hours later…
4:25 PM
Is there an easy way to figure out what data is being sent in a packet I have a struct that looks like this
typedef struct AUTH_LOGON_PROOF_C
{
    uint8   cmd;
    uint8   A[32];
    uint8   M1[20];
    uint8   crc_hash[20];
    uint8   number_of_keys;
	uint8   securityFlags;                                  // 0x00-0x04
} sAuthLogonProof_C;
If I look at the packet in wireshark, I can only see A, M, and crc_hash, number_of_keys
But I believe securityFlags is being set by the packet as well, but why can I not see the securityFlags in the packet
Also I believe there should be other properties set by the packet but I just don't know what the protocol is, is there any way to debug it, I've added uint8 authCode[16]; to the struct and its value prints out some random crap like dâ–’â–’â–’4â–’â–’Uâ–’{&&[
Any suggestions
 
5:01 PM
the error is on the line 32
 
5:24 PM
@Lalaland There were a few others (e.g., APL and SNOBOL). In SNOBOL's case, there wasn't much alternative though--functions didn't really have syntax to define a scope.
 
user406009
5:38 PM
@Datsik The actual layout of that struct will be really annoying due to padding and whatnot. If you actually want to send that struct over the network and read it out elsewhere, you should mark that the structure should be "packed"
 
user406009
I believe it's pragma packed in MSVC
 
5:54 PM
@Lalaland Given that all the components have type uint8 (or arrays thereof) it probably won't make any difference in this case. In most typical cases, the compiler will only insert padding to get a field to an address that's a multiple of the size of its type, and in the case of uint8, that means it never inserts any padding.
 
user406009
Yeah, that's probably right.
 
6:37 PM
Hey there i have a question about valgrind and c++. Basically i have built a linkedList and i am checking for leaks in memory from the remove_front/back member functions.The problem is that when i comment out the part of the code that deletes the node that is to be removed the valgrind gives deferent output when i delete the same number of nodes from front and from back.
Valgrind states that the same number of bytes are leaked but in one case "definitely lost: 48 bytes in 3 blocks" and on the other "definitely lost: 16 bytes in 1 blocks" plus "indirectly lost: 32 bytes in 2 blocks".
Has this anything to do with my cpp code or is it a valgrind thing?
 
7:34 PM
@theVoid I would guess it's telling you that when you delete the head of the list, you're doing something like head = nullptr;. This directly leaks the block of memory at the head of the list, and indirectly leaks the other two it's pointing at.
 
7:50 PM
@theVoid no, it's definitely your code
always assume it's your code
it's simple: what is more likely to have an obvious bug: your program written by one person, in a few hours, used by one person; or a utility written by hundreds of people over several years, used on daily basis by thousands of people?
don't go that way, by starting with an assumption that the problem is somewhere else
that way lies madness
@theVoid Might as well blame it on the little digital dwarves living inside your computer
 
@milleniumbug In a choice between my code and valgrind, I feel safe assuming a problem in valgrind as a rule. :-)
 
ok so with the deletes i get 0 leaks on both cases this happens only when i comment out the delete part.Also @milleniumbug i agree the bug is definitely in my code lol.
yea i was an idiot saying that there is literally zero chance that the bug is in valgrind.
:)
 
8:20 PM
@Lalaland so are you saying that if I was to add any extra uints to the strict it will automatically get inserted into the property?
@Lalaland and I'm receiving the data into that struct from the client, not sending it out from the server
 
@milleniumbug @JerryCoffin Thank you very much :-)
 
8:46 PM
I'm trying to use/write a DirectShow Filter and application with Visual Studio and I can't even find how to install the libraries/headers needed or where it may be. Can anyone help?
 
we know as much about "DirectShow Filter" as you
have you tried googling "DirectShow Filter visual studio" or similar
 
 
1 hour later…
10:00 PM
@Link They're included in the Windows SDK. If memory serves, there was a time when the DirectShow headers/libs were part of the DirectX SDK though. If you're using an SDK that old, you probably don't want to get a matching DirectX SDk--you want to update.
 
@Link Directshow is deprecated last I checked
why not do media foundation?
that way it works on anything supported?
 
11:04 PM
@JerryCoffin How come the uint8 basically says it needs no padding? Is there somewhere I can read up on these protocols or whatever you call it?
 
@Mgetz @JerryCoffin Yeah, I found the libraries headers, but I still can't use them. @Mgetz Is it possible to use Media Foundation to make a virtual webcam? I'm trying to stream a desktop region
 
@Mgetz Can you explain what it means by this line: Starting in Windows 7, Media Foundation automatically supports audio and video capture devices. Does this mean that I only have to get the desktop and the stuff to make it into a 'webcam' is already done?
 
11:22 PM
@Link I think that means it automatically supports cameras and such
but it also means that if you pretend you're a camera it should work
it looks like if you provided a kernel streaming minidriver it would do it
but I suspect that already exists
or will exist soon
 
Okay
 
it appears there may be a standard capture codec
 
Can you link me where I could find it? Been trying to deal with the headache that is Directshow for a few days now
 
see if you can find it in graphedit
sorry use topoedit
that will allow you to see all the devices
I'm not seeing a standard one
you could probably easily write a MF source that just captures frames from the desktop
 
Okay
So it captures frames from desktop
And then it presents them as a driver or what?
Cause in directshow you had to use some output pin or such and make it work
 
11:35 PM
1
A: Can Video capture in windows media foundation used for screen capturing?

Rudolfs BundulisFor desktop screen capture you should look at the output duplication feature implemented through IDXGIOutputDuplication. What you do is obtain the DXGI object for the video adapter you need, enumerate the outputs to find the needed one (or all if you do a simultaneous capture from multiple screen...

better
there is actually a sample
 
Thank the gods
 
that is for capture
making a source from that shouldn't be too hard in and of itself
as you just need to create frames
once you have a source it's just a matter of assembling a topography and then running it
in theory at least
I did it before for VGM files
it wasn't horrible
 
Okay
 
you'd think this would be a standard capture device
but I suspect there are security reasons to not do that
 

« first day (198 days earlier)      last day (2661 days later) »