#why

41 messages · Page 1 of 1 (latest)

robust topaz
#

why does this work with out errors

include "stdio"

main()
{
int charin;
while ( (charin = getchar())!=32)
putchar(charin);
}
but when i add it to the program i get an identifier expected in a type declaration

#include "stdio"

void drawLine()
{
int y;
int x;
y=30;
gotoxy(1,1);
for (x = 0; x < 180; x++){

printf("the value of x is %d                    ",x);
    }

}
int main()
{
int charin;
clearscr();

gotoxy(10,5);
printf("Hello World from Vintage is The New Old!\n");

drawLine();

gotoxy(35,15);
printf("Press <ENTER> to finish...");

while ( (charin = getchar()) !=32)
putchar(charin);

return 0;

silver tundraBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

silver tundraBOT
#

why does this work with out errors

include "stdio"

main() {
  int charin;
  while ((charin = getchar()) != 32)
    putchar(charin);
}
but when i add it to the program i get an identifier expected in a type
    declaration
#include "stdio"

    void
    drawLine() {
  int y;
  int x;
  y = 30;
  gotoxy(1, 1);
  for (x = 0; x < 180; x++) {
    printf("the value of x is %d                    ", x);
  }
}
int main() {
  int charin;
  clearscr();

  gotoxy(10, 5);
  printf("Hello World from Vintage is The New Old!\n");

  drawLine();

  gotoxy(35, 15);
  printf("Press <ENTER> to finish...");

  while ((charin = getchar()) != 32)
    putchar(charin);

  return 0;
RossWeikle
robust topaz
#

i am sorry the first section works without errors

#

but the second gives the error identifer expected in a type declaration

#

main() {
int charin;
while ((charin = getchar()) != 32)
putchar(charin);
}

#

no error works as expected

#

main() {
int charin;
while ((charin = getchar()) != 32)
putchar(charin);
}
but when i add it to the program i get an identifier expected in a type
declaration
#include "stdio"

void
drawLine() {

int y;
int x;
y = 30;
gotoxy(1, 1);
for (x = 0; x < 180; x++) {
printf("the value of x is %d ", x);
}
}
int main() {
int charin;
clearscr();

gotoxy(10, 5);
printf("Hello World from Vintage is The New Old!\n");

drawLine();

gotoxy(35, 15);
printf("Press <ENTER> to finish...");

while ((charin = getchar()) != 32)
putchar(charin);

return 0;

#

}

#

does not and gives the error

sharp harness
#

Can you show the full error list

robust topaz
#

1 ERRORS DETECTED

2 Identifier expected in a type declaration

sharp harness
#

;compile -std=c89

#include <stdio.h>
/*main() {
  int charin;
  while ((charin = getchar()) != 32)
    putchar(charin);
}*/

void
    drawLine() {
  int y;
  int x;
  y = 30;
  gotoxy(1, 1);
  for (x = 0; x < 180; x++) {
    printf("the value of x is %d                    ", x);
  }
}
int main() {
  int charin;
  clearscr();

  gotoxy(10, 5);
  printf("Hello World from Vintage is The New Old!\n");

  drawLine();

  gotoxy(35, 15);
  printf("Press <ENTER> to finish...");

  while ((charin = getchar()) != 32)
    putchar(charin);

}```
quartz sapphireBOT
#
Compiler Output
/opt/compiler-explorer/gcc-15.1.0/bin/../lib/gcc/x86_64-linux-gnu/15.1.0/../../../../x86_64-linux-gnu/bin/ld: /tmp/ccHRccN4.o: in function ​`drawLine':
<source>:13:(.text+0x1f): undefined reference to ​`gotoxy'
/opt/compiler-explorer/gcc-15.1.0/bin/../lib/gcc/x86_64-linux-gnu/15.1.0/../../../../x86_64-linux-gnu/bin/ld: /tmp/ccHRccN4.o: in function ​`main':
<source>:20:(.text+0x5f): undefined reference to ​`clearscr'
/opt/compiler-explorer/gcc-15.1.0/bin/../lib/gcc/x86_64-linux-gnu/15.1.0/../../../../x86_64-linux-gnu/bin/ld: <source>:22:(.text+0x73): undefined reference to ​`gotoxy'
/opt/compiler-explorer/gcc-15.1.0/bin/../lib/gcc/x86_64-linux-gnu/15.1.0/../../../../x86_64-linux-gnu/bin/ld: <source>:27:(.text+0x9b): undefined reference to ​`gotoxy'
collect2: error: ld returned 1 exit status
Build failed
robust topaz
#

TRS80 C VERSION: 02.01.00 09:49:42 07/14/25 PAGE 1
|----------------------------------------------------------------------|
1|#include "stdio"
2|/*************** Alcor C Standard I/O Header /
3|
4|#define MAXFILES 20
5|#define EOF -1
6|#define NULL 0
7|#define stdin _iob[0]
8|#define stdout _iob[1]
9|#define stderr _iob[2]
10|#define getchar() getc(stdin)
11|#define putchar(c) putc(c,stdout)
12|
13|typedef struct {
14| char file[32]; /
file descriptor /
15| int fd; /
file descriptor number /
16|} FILE;
17|
18|extern FILE _iob[MAXFILES];
19|
20|typedef struct {
21| int length;
22| char string[80];
23|} STRING;
24|
25|/
*******************************************/
26|
27|void drawLine()
28|{
29|int y;
30|int x;
31|y=30;
32|gotoxy(1,1);
33|for (x = 0; x < 180; x++){
34|
35| printf("the value of x is %d ",x);
36| }
37|}
38|int main()
39|{
40| int charin;
41| clearscr();
42|
43| gotoxy(10,5);
44| printf("Hello World from Vintage is The New Old!\n");
45|
46| drawLine();
47|
48|
49| gotoxy(35,15);
50| printf("Press <ENTER> to finish...");
51|
52| while ( (charin = getchar()) !=32)
53| putchar(charin);
54|
55| return 0;
56|
57|
***** ^ 2

TRS80 C VERSION: 02.01.00 09:49:42 07/14/25 PAGE 2
|----------------------------------------------------------------------|

     1 ERRORS DETECTED

2 Identifier expected in a type declaration

#

if i remove the int charin; line and the while line i get no error.

ebon palm
#

!code

silver tundraBOT
#
How to Format Code on Discord
Markup

```c
int main() {}
```

Result
int main() {}
ebon palm
#

Show a screenshot of the error

robust topaz
ebon palm
#

Ah, the ***** ^ 2 thing is pointing at the error isn't it?

#

Looks like you just forgot the } at the end

#

But also what the hell is this stone age compiler? nooo

#

Please shame your teaches into using something more modern

robust topaz
#

i am playing around with a retro pc. i want to make an program to interface a piec of hardware and i want to learn C programming i am 62 years old and the teachers had nothing to do with it

ebon palm
#

Ah, sorry for the assumption then 🙂

robust topaz
#

dang i thought i had checked on the final } but i must have deleted it in my ancient editor

hollow vale
robust topaz
#

no problem on the assumption. i know i am going at the is a backwards way

hollow vale
#

Didnt know all I had to get was shamed on my skill and knowledge, and Ill just do better. Hell yeah! 😒

hollow vale
robust topaz
#

i took some classes years ago on c but have always been a basic programmer and using a 1979 complier and editor (k and r c btw) so i know that there will be some problems that will be difficult to resolve, but a dang } should not have been one of them

ebon palm
#

I don't think I've said anything out of line? thinkies

#

Of course, nothing wrong with using it yourself intentionally

robust topaz
#

i took no offense i i also understand about outdate tech. espcially with open source stuff available to use.

#

there is like maybe 3 native compilers for the trs80 model 4. this one is just the first i was able to get working but i will try the others plus there are cross compilers for the PC (linux and windows) that i will have to work with later

#

i also understand i will have to make adjustments to use this knowledge in the pc world