CIN function failing....

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
bluechill
Posts: 21
Joined: Tue Oct 20, 2009 8:10 pm
Contact:

CIN function failing....

Post 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;
}
Last edited by bluechill on Mon Dec 14, 2009 6:53 am, edited 2 times in total.
FrostOS Lead Developer
OS Developer
User avatar
gzaloprgm
Member
Member
Posts: 141
Joined: Sun Sep 23, 2007 4:53 pm
Location: Buenos Aires, Argentina
Contact:

Re: CIN function failing....

Post 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
Visit https://gzalo.com : my web site with electronic circuits, articles, schematics, pcb, calculators, and other things related to electronics.
User avatar
bluechill
Posts: 21
Joined: Tue Oct 20, 2009 8:10 pm
Contact:

Re: CIN function failing....

Post 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.
Last edited by bluechill on Sun Dec 13, 2009 9:27 pm, edited 3 times in total.
FrostOS Lead Developer
OS Developer
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: CIN function failing....

Post 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.
Last edited by neon on Sun Dec 13, 2009 9:21 pm, edited 1 time in total.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
bluechill
Posts: 21
Joined: Tue Oct 20, 2009 8:10 pm
Contact:

Re: CIN function failing....

Post 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....
FrostOS Lead Developer
OS Developer
AUsername
Member
Member
Posts: 54
Joined: Sun Feb 01, 2009 9:07 pm

Re: CIN function failing....

Post 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.
User avatar
bluechill
Posts: 21
Joined: Tue Oct 20, 2009 8:10 pm
Contact:

Re: CIN function failing....

Post 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.
FrostOS Lead Developer
OS Developer
whowhatwhere
Member
Member
Posts: 199
Joined: Sat Jun 28, 2008 6:44 pm

Re: CIN function failing....

Post 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....
Post Reply