« first day (138 days earlier)      last day (2721 days later) » 

3:43 AM
Hey Guys, I had a question, I am asking the user to put their first last name and age and I want to find each and save it into its own data. I can't figure out how to find the age whithin the string. they will be seperated with space for example : Mike Jones 30
I want to store Mike == firstName Jones == lastName 30 == age; heres what I have so far.
if(pos != string::npos)
{
string firstName = str.substr(0, pos);

string lastName = "";

if(pos < str.length() -1){
lastName = str.substr(pos + pos) ;
 
1 message moved from Lounge<C++>
 
Thank you @milleniumbug
Please disregard that code:
if(pos != string::npos)
{
string firstName = str.substr(0, pos);

string lastName = "";

if(pos < str.length() -1){
lastName = str.substr(pos + 1) ;
}
fullName = lastName + firstName ;
}
 
using std::stringstream would be the simplest option
Otherwise you need to find spaces, and continue finding by starting from previous index
 
:) Hey, does anyone know how to edit the firmware of a mouse?
 
Yeah, That's what I was wanting to do.
 
3:48 AM
@user6582640 No, most of the mice aren't really programmable
 
would it be str.substr(lastName +1 ) ?
 
thank you so much @milleniumbug
 
@fsfh60 no it wouldn't
 
So I guess it helps to explain my goal first. I want to increase the sensitivity of a mouse when a button is pushed, but don't know where to begin.
It seems like the challenging part is finding out how to modify the mouse first, but programming it should be (I'm guessing) easier
 
if by changing senstivity you mean "changing how fast the mouse cursor moves" then you can register for global mouse events and wait for specific button gets pressed or unpressed, and then you call specific function to change the speed. If you mean "change actual sensitivity" like you do on some gaming mice, well, that's more difficult because you'd need to inform the mouse so it changes dpi, and, obviously it will only work on selected mice
and it will be very hardware specific
 
3:58 AM
<thinks>
I guess it has to be done through software, since I want to preserve the functionality of the mouses forward and backward buttons outside of video games
for example, I want it to behave normally when browsing the web
 
@milleniumbug would you recemmend me doing this ? std::size_t found = str.rfind(" ");
 
I have a basic understanding of electrical engineering and some experience with trying to interface a robotic arm, but idk how to access the mouse's firmware (if possible)
 
the circuit diagram for the intellimouse isn't too complex
Okay, I'm looking up "How to program a microcontroller", and that seems pretty promising. Is there a way to download the machine code that's already on the microcontroller? I assume yes because the computer has to be able to read it?
 
Thank you @milleniumbug I am gonna try to include now part of a Struction and from a file.
 
4:12 AM
why should a computer need to read mouse's firmware
 
Structure *
 
the answer is: it doesn't, just like you don't need to read my brain in order to know what I'm typing here
 
haha
 
Also you're assuming a mouse has an actual firmware and not an integrated circuit which is not programmable in any way whatsoever
 
crap
that makes sense that it would
 
4:16 AM
Unless you have some high-end mouse, I'd say the chance is slim
 
it's an intellimouse (classic gaming mouse). Not a new laser mouse or anything
Could it be done with a registry hack, then?
 
can you change dpi on your mouse from some kind of program they distributed with your mouse?
 
No, it's just a plug and play mouse
 
Hey @milleniumbug and ideas whats wrong with my code all its output is 0
I have inputed a txt file
Mike Jones 26
Chris Ashkar 200
 
@user6582640 then I'd say the best thing you can do would be an equivalent of changing these options, but in some automatic way
You'd need to write a program which waits for mouse button press and release, and then call a WinAPI function which corresponds to this setting
@fsfh60 is the file opened correctly
 
4:29 AM
Yes sir.
 
How do you know this
 
I would get a run time error
and it would automatically close.
But its actually outputing 0
 
@fsfh60 How naive
 
:(
 
go read the docs of the functions you call because clearly something different happens
Also go check whether your file is open
 
4:36 AM
Okay
 
4:51 AM
I am so confused.
 
5:05 AM
I added a loop while(!fin.eof())
Nothing shows up now. I am doing something wrong and its so irritating LOL
I am getting standard input empty
 
 
3 hours later…
8:41 AM
Hello
 
 
11 hours later…
7:17 PM
I must be missing out on something, but how do you compile a final build that is targeting the real audience? A build that is able to run on any windows operating system? The .exe file I compiled could only run on my computers that had visual studio installed.. Why is that?
 
1 message moved from Lounge<C++>
@JohanSundman Computers must have Visual C++ Runtime installed
 
Do I have to force them to install it?
 
in general you'll often run programs without forcing users because often they'll have it installed because of other programs
...
 
:]
okay
Soo.. I'm going to need an "installation wizzard"?
 
normally you'd install it together with an installer for your software, yes, but obviously it's not gonna work if your goal is to sneak around
 
7:22 PM
@JohanSundman interesting...?
 
@milleniumbug So what is the easiest way to install that shit?
@JonClements Don't know if you could call it a cirus really x) It's an infinite loop that offsets your current mouse position ~10 times per second
virus*
offsets it randomly*
 
that's nice - but you're attracting flags and peeing off rooms it appears - how about we desist such behaviour?
 
yea sure
All I wanna know is how I can make my code run on any windows computer
 
7:49 PM
@JohanSundman abuse is close enough. You know what the good thing is to "barrier to entry"? It makes it harder for someone to case a nuisance/damage out of sheer boredom.
Of course, you can always refer to script kiddie sites, but we ain't such a site.
@JohanSundman So we're not obliged to help. Had you not told us, we would have told you to RTFM, right now, I'd advise you to NRTFM
 
 
2 hours later…
9:55 PM
Hi, I'm a complete beginner to C++ and I was looking at template specialization and came across some unintuitive behavior
I figured that the specialized version of the template would "inherit" from the more general definition
 
@danem well it doesn't
 
so whenever you specialize a template you need to rewrite all member variables and methods for that instance?
 
you can extract shared part into common base class but beware of lookup issues in dependent base classes
 
what do you mean by "dependent base classes"?
 
template<typename T> class whatever : whatever_base<T> // <- whatever_base<T> is a dependent base class
 
10:00 PM
What lookup issues would it cause? Just cases where the member variable or method being referenced is ambiguous?
 
you need to look up data members and functions in dependent base classes with this->member, simply saying member won't suffice
and types with typename whatever_base<T>::type
 
ok
thanks for the pointers
 
11:01 PM
The behavior of vectors is also confusing to me. I understand that to put an object/value into a vector it needs to be copied as the vector doesn't know anything about its lifetime. To avoid an extra copy I should be able to use emplace_back. In this example however, it appears to be calling both the constructor and copy constructor several time, seemingly out of order.

What's also confusing to me is that I print out the value of a reference to a member of the vector after it has been cleared, yet the data is still valid. References are just syntactic sugar for pointers right? How can that
 
> I print out the value of a reference to a member of the vector after it has been cleared, yet the data is still valid.
undefined behaviour is undefined
 
So what i do from line 30 to 32 is undefined behavior? So, that means that the clear method of vector doesn't actually touch the data it holds in this implementation?
 
@danem wrt the first: reallocation happens
 
Ah, so the vector is resizing itself and has to move the values?
that makes sense
 
yes and since you've declared the copy constructor the move constructor is not generated
so a copy constructor is called
@danem the data is destroyed by calling the destructor for each element
of course as-if rule applies when the destructor does nothing
 
11:16 PM
That's with regard to my second question, right? So you're saying, that the only guarantees it makes is that the destructor for each will be called, and in my case there really isn't anything to destruct, my data will just so happen to be left in tact?
 
well, it's undefined
it could as well fill the bytes with zero afterwards
 
right, right. Okay that makes sense
 
or with 0xCC
@danem or crash
 
Thanks for all the help btw
 
or...
@danem appearing to work is the worst you can ask for
because you won't detect it until much later
 
11:24 PM
right. i program in C fairly often so I've experienced many bugs like that
 
yes, then you know what I mean
at least here, you can opt-in into bounds checked interface with .at()
instead of using []
 
11:54 PM
Ok, another stupid question that relates to my initial one. Let's say you (for some reason) want to represent a vector as a singly linked list, and you wanted to have two versions. One version uses references and the values of the nodes aren't copied. The other version copies each value.

Here's my attempt, but it seems pretty ugly. http://ideone.com/3w1TK3
I was trying to use template specialization to accomplish this originally, but when I had added the parent class I couldn't figure out how to "specialize it"
 
> want to represent a vector as a singly linked list
wut
are you storing vectors inside a linked list
are you implementing your linked list
 
yes, i know its contrived. I'm just messing around, trying to learn how the template system works
i'd never do this in practive
practice
 
std::list <- doubly-linked list, std::forward_list <- singly-linked list BTW
 

« first day (138 days earlier)      last day (2721 days later) »