I figured it out. I was using "/n" instead of endl and that was screwing up cin.getline and getch
Now I've got a few more problems, but those should be easy. Just one question. How can you determine if a file already exists? The function always returns that that the file exists...
I've heard often that one should never use gets. I've been told to use cin.getline instead.
Does anyone know if gets could seriously mess up one's compiler if used frequently?
I'm sorry. There's probably nothing wrong with cin.getline.
The same thing is happening with getch.
It's something SERIOUSLY wrong with my compiler. I'm going to try reinstalling it.
I'm trying to write a program that frequently prompts for char arrays. I've been told to stay away from the gets function. Yet when I run the progam, it does something very strange. It skips the cout command that precedes it and then displays the text AFTER the prompt. And there are other...
Still not working. It compiles and executes, but it does very weird things...
Please help.
#include <iostream.h>
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
#include <fstream.h>
void get(char prompt[100], char input[100]) //get(prompt, variable);
{//get -...
Thanks. Most of that was very helpful. However, I can't figure out how to copy a string starting in the middle of the string. With .assign, it's easy, you just enter where you want the copying to start. I haven't found a function (or a sequence of functions) in <string.h> that will allow me...
Okay. I'm used to using Microsoft Visual C++ v6.0, but I have v4.0 at home. I'm used to adding strings the way you'd add numbers. I'm used to using string.assign() and string.find() for all of my purposes. But I can't use them any more. So I was wondering what tools for manipulating strings...
Ha! Never mind! I DON'T use it! Simple as that!
What does c_str() do, anyway?
The syntax I use it in is
fin.open(string.c_str())
note: fin is the ifstream command I use
If only it was so simple.
<string> does not exist in C++ v4.0.
And using namespace std; is automatically built in so if you try to use it, it'll give you an error message.
Okay. I have C++ 4.0 at home and I can't get strings to work. From what I've heard, this because at the time 4.0 came out, string wasn't "standard." At first I thought this had to do with the header files I was using. But does it have something to do with namespaces? Do I have to...
Alright. I'm at school. string and string.h are two COMPLETELY different header files. My home computer doesn't have string (tho I suppose I could take it home). So that's probably the problem. Does ANYONE know what header files I'd need to do the same thing as "string"?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.