| www.delorie.com/archives/browse.cgi | search |
| From: | "Matt Firewalker" <arenaproject AT hotmail DOT com> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Problem with cin.get |
| Lines: | 47 |
| X-Newsreader: | Microsoft Outlook Express 4.72.3155.0 |
| X-MimeOLE: | Produced By Microsoft MimeOLE V4.72.3155.0 |
| Message-ID: | <AFwg4.1236$Pb4.9680@newsfeed.slurp.net> |
| Date: | Sun, 16 Jan 2000 20:15:24 -0800 |
| NNTP-Posting-Host: | 206.170.166.92 |
| X-Trace: | newsfeed.slurp.net 948082400 206.170.166.92 (Sun, 16 Jan 2000 22:13:20 CDT) |
| NNTP-Posting-Date: | Sun, 16 Jan 2000 22:13:20 CDT |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Every time I use cin.get, my program seems to skip right past it. It
doesn't matter what I am trying to do with it; I pass in an array of
characters and a number of characters to read, that's it. Is there
something wrong nyah?
Some samples of a use: I use cin.get to get a weapon name from the user.
But the programs skips it!
Any help would be appreciated
~Matt F.
#include <stdio.h>
#include <iostream>
int main()
{
FILE *f = fopen("Wpnname.255","wb");
rewind(f);
long int Count; // the number of weapons to input
int c;
cout << "How many weapons would you like to enter? ";
cin >> Count;
char *buffer = new char[40];
for (c = 0; c < Count; c++)
{
cout << "\n\nEnter name number " << c+1 << ": ";
cin.get(buffer, 39);
if (write_name(f,buffer) == 1)
{
cout << "Error writing to file";
return -1;
}
delete [] buffer;
buffer = new char[40];
}
fclose(f);
return 0;
}
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |