Page 1 of 1
CIN function failing....
Posted: Sun Dec 13, 2009 8:26 pm
by bluechill
Ok here so after working on my OS in my team of 6 we have come across a bug. We wrote a cin function (see attached file istream.cpp) and well.... I can get input but it just doesn't work it doesn't save the keyboard input to the char*. You can see this in the build of this (see
here). and if you haven't already guessed, were making the OS in c++. Also the ISO contains GRUB 2 (not legacy) and is bootable by vmware fusion 3 and qemu with the same results for each so it is something with our code (same results = not outputting input to char*) oh and here is the code for the cin (in main)
Code: Select all
char* command = "";
while (true)
{
cout << ":> ";
cin >> command;
cout << "Command: " << command;
}
Re: CIN function failing....
Posted: Sun Dec 13, 2009 8:54 pm
by gzaloprgm
First: "cin" is NOT a function, it's an object.
Second: Some enums in istream.cpp should really be in the .h
Third: "Oh and please this is not an Open Source OS yet so don't copy our code...." Some of your code seems stolen from neon's (brokenthorn) tutorials.
Fourth: your char *command is not initialized! you should allocate some space for it, either by doing char* command = malloc(somenumber); or char command[fixed];
Cheers,
Gzaloprgm
Re: CIN function failing....
Posted: Sun Dec 13, 2009 9:15 pm
by bluechill
brokenthorn? oh and no we didn't take code from him. And yes I know it is an object but seriously do you have to correct me on all these little things?
Just out of curiosity, what code do you think is stolen?
Edit: that fixed it, thank you.
Re: CIN function failing....
Posted: Sun Dec 13, 2009 9:18 pm
by neon
Hello,
i isnt initialized in your IStream::operator>> routine but is used as an index when writing to cp. Id be surprised if it worked.
Re: CIN function failing....
Posted: Sun Dec 13, 2009 9:20 pm
by bluechill
yeah I know I fixed that just before I fixed the char initialized it because well it would just loop and then never let the user enter commands
Edit: now to go and fix why the characters are printed twice for every one key stroke....
Re: CIN function failing....
Posted: Sun Dec 13, 2009 9:43 pm
by AUsername
gzaloprgm wrote:Third: "Oh and please this is not an Open Source OS yet so don't copy our code...." Some of your code seems stolen from neon's (brokenthorn) tutorials.
bluechill wrote:brokenthorn? oh and no we didn't take code from Mike.
I like how no one said neon's name was Mike, and yet you called him by his real name.
Especially considering how you claim you didn't take any code from his tutorials, which is really the only place his name is mentioned. Not only that but you claim you don't know what BrokenThorn in.
Also, I like how you edited your post to remove Mikes name.
Re: CIN function failing....
Posted: Sun Dec 13, 2009 10:18 pm
by bluechill
lol, I contacted him about converting those tutorials to use gcc not visual studio 2008 a while ago and I didn't write this code, a person on my team did but he was having trouble so he went and worked on memory management and then I went and tried to fix his code and so HE not me might of taken the code but I didn't, Mike can confirm this. I was just writing it and I haven;t thought of brokenthorn in a while and so I was think of what that was and was merely expressing that in my post. So maybe he did take code from him in in that case I guess I ask him about that.
Edit: the reason I changed it was because I thought people were calling him neon instead of Mike here and so out of courtesy I changed it.
Re: CIN function failing....
Posted: Mon Dec 14, 2009 8:26 pm
by whowhatwhere
bluechill wrote:lol, I contacted him about converting those tutorials to use gcc not visual studio 2008 a while ago and I didn't write this code, a person on my team did but he was having trouble so he went and worked on memory management and then I went and tried to fix his code and so HE not me might of taken the code but I didn't, Mike can confirm this. I was just writing it and I haven;t thought of brokenthorn in a while and so I was think of what that was and was merely expressing that in my post. So maybe he did take code from him in in that case I guess I ask him about that.
Edit: the reason I changed it was because I thought people were calling him neon instead of Mike here and so out of courtesy I changed it.
Ahh yeah that does tend to happen sometimes, especially when
contracting out the services of a third party....