Hi, I'm learning c++ programming and Im currently stuck on an example from the text book I'm reading from (ugh im really not liking this book)... anyways the book is giving me this code as an example of a c-string program and to better understand how it works I copied it into my compiler and tried to give it a run, but it gives me this error everytime :
18 C:\Dev-Cpp\10.1.2.cpp expected unqualified-id before '{' token
18 C:\Dev-Cpp\10.1.2.cpp expected `,' or `;' before '{' token
Im pretty sure that theres nothing horribly wrong with the example in the book (from what I can tell from what ive learned in the books previous chapters) but for the life of me I cant figure out why the error is coming up... Im sure its something simple or maybe its something Ive done(or not done) anyways any help would be appreciated! thanks in advance.
Heres the program:
#include <iostream>
using namespace std;
const int MAXCHARS = 81;
void getaline(char []);
int main()
{
char message[MAXCHARS];
cout << "Enter a sentence:\n";
getaline(message);
cout << "The sentence just entered is: ";
cout << message << endl;
}
void getaline(char strng[])
{
int i = 0;
char c;
while(i < MAXCHARS && (c = cin.get ()) != '\n')
{
strng[i] = c;
i++;
)
strng[i] + '\0';