-2

I wrote the following code. It is to implement a doubly-linked list. But errors popped up.

while(x==1); // This line showed errors
return 1;

Errors:

DoublyLinkedList.c: In function `main':
DoublyLinkedList.c:194: error: stray '\226' in program
DoublyLinkedList.c:194: error: stray '\128' in program
DoublyLinkedList.c:194: error: stray '\156' in program
DoublyLinkedList.c:194: error: `The' undeclared (first use in this function)
DoublyLinkedList.c:194: error: (Each undeclared identifier is reported only once
DoublyLinkedList.c:194: error: for each function it appears in.)
DoublyLinkedList.c:194: error: parse error before "list"
DoublyLinkedList.c:194: error: stray '\226' in program
DoublyLinkedList.c:194: error: stray '\128' in program
DoublyLinkedList.c:194: error: stray '\157' in program

What is the stray error? What are those random numbers?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Gabinux
  • 11
  • 1
  • 1
  • 1
  • 2
    The line producing the errors is line 194. That is neither of the lines of code you've quoted. – me_and Aug 24 '12 at 15:46
  • @me_and: Yes, it just adds confusion to include that code. – Peter Mortensen Mar 06 '21 at 12:35
  • The numbers are supposed to be octal. 128 is not a valid octal number. – Peter Mortensen Mar 06 '21 at 12:59
  • Perhaps the numbers are decimal with the particular compiler, compiler version, and compiler configuration? – Peter Mortensen Mar 06 '21 at 14:17
  • 1
    Yes, 226 decimal is the signature 342 octal (hexadecimal 0xE2). Thus, a much more direct analysis is 226 128 156 → 0xE2 0x80 0x9C → UTF-8 sequence for Unicode code point U+201C [LEFT DOUBLE QUOTATION MARK](https://www.utf8-chartable.de/unicode-utf8-table.pl?start=8192&number=128). Most text editors (e.g. [Geany](https://en.wikipedia.org/wiki/Geany) (Linux and Windows) and [Notepad++](https://en.wikipedia.org/wiki/Notepad%2B%2B)) with a [regular expression](https://en.wikipedia.org/wiki/Regular_expression) mode will be able to do search/replace for Unicode code point U+201C, using `\x{201C}`. – Peter Mortensen Mar 06 '21 at 14:53
  • What are ***decimal*** stray numbers a signature of? [Turbo](https://en.wikipedia.org/wiki/Turbo_C%2B%2B)/Borland C/C++? [Clang](https://en.wikipedia.org/wiki/Clang)? [Visual Studio](https://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B)? A particular compiler configuration? Something else? – Peter Mortensen May 23 '23 at 12:58

2 Answers2

5

I cut pasted some code from a Microsoft Word document. The minus sign was displayed by my text editor, but it was actually a value of octal 226 or hexadecimal 96. The minus sign should have been a hex 2D. I could see it when I opened my code as a binary file - the octal 226 got displayed in the ASCII listing as a block.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user3642992
  • 51
  • 1
  • 1
2

Your DoublyLinkedList.c appears to contain text that is not valid C. Those numbers are the octal values of characters that are not valid in a C program.

If you meant to put a descriptive comment at the start of your source file, make sure that each line of your comment begins with //.

while(x==1);

is a while loop with an empty body (i.e. the final semi-colon). If x is 1 your program will loop endlessly.

Nicola Musatti
  • 17,834
  • 2
  • 46
  • 55