/*
* echoString2.c
* Echoes a string entered by user. Converts input
* to C-style string.
* Bob Plantz - 19 June 2009
*/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
int main(void)
{
char aString[200];
char *stringPtr = aString;
write(STDOUT_FILENO, "Enter a text string: ",
strlen("Enter a text string: ")); // prompt user
read(STDIN_FILENO, stringPtr, 1); // get first character
while (*stringPtr != ’\n’) // look for end of line
{
stringPtr++; // move to next location
read(STDIN_FILENO, stringPtr, 1); // get next character
}
*stringPtr = ’\0’; // make into C string
// now echo for user
printf("You entered:\n%s\n", aString);
return 0;
}
and these are my errors
21 2 Untitled1.cpp [Error] stray '\222' in program
21 2 Untitled1.cpp [Error] stray '\' in program
21 2 Untitled1.cpp [Error] stray '\222' in program
26 2 Untitled1.cpp [Error] stray '\222' in program
26 2 Untitled1.cpp [Error] stray '\' in program
26 2 Untitled1.cpp [Error] stray '\222' in program
Untitled1.cpp In function 'int main()':
21 25 Untitled1.cpp [Error] 'n' was not declared in this scope
Most likely your teacher wrote this in MS Word or similar, which formatted the code with the weird quote characters. Just retype the quotes yourself as normal quote characters.