Please help me for my first program in C

Status
Not open for further replies.

kgavionics

Full Member level 3
Joined
Jun 12, 2012
Messages
167
Helped
7
Reputation
14
Reaction score
11
Trophy points
1,298
Location
Alberta.Canada
Visit site
Activity points
2,482
hi
i'm back after a long period of absence due to my studies.Before i used to wirte my all my program in assembly and now i just began C and i have a little issue

Here's my program:

Code:
#include <p18f452.h>

void main(void)
 { 
  
	 unsigned char z;
	 TRISB=0
	 for (z=0;z<=255;z++)
		 PORTB=z;
	 
   while (1)  ;
 }
the problem that MplabX is not reconizing my command at all.
here's the output file error message

Code:
make -f nbproject/Makefile-default.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `C:/Users/adam/MPLABXProjects/myfirstc.X'
make  -f nbproject/Makefile-default.mk dist/default/production/myfirstc.X.production.hex
make[2]: Entering directory `C:/Users/adam/MPLABXProjects/myfirstc.X'
"C:\Program Files (x86)\Microchip\mplabc18\v3.46\bin\mcc18.exe"  -p18C452 -ms -oa-  -I "C:\Program Files (x86)\Microchip\mplabc18\v3.46\bin"\\..\\h  -fo build/default/production/blink.o   blink.c 
C:\Users\adam\MPLABXProjects\myfirstc.X\blink.c:7:Error: syntax error
make[2]: *** [build/default/production/blink.o] Error 3
make[2]: Leaving directory `C:/Users/adam/MPLABXProjects/myfirstc.X'
make[1]: *** [.build-conf] Error 2
make[1]: Leaving directory `C:/Users/adam/MPLABXProjects/myfirstc.X'
make: *** [.build-impl] Error 2

BUILD FAILED (exit value 2, total time: 1s)
by the way, i have successfully installed the student version c18 compiler.

can someone help me please.

thanks in advance
 

hi guys
after some verifications, i made some change to the file

Code:
/* 
 * File:   newmain2.c
 * Author: adam
 *
 * Created on December 20, 2013, 4:26 PM
 */

#include <stdio.h>
#include <stdlib.h>
#include <p18f452.h>
#define _XTAL_FREQ 20000000

/*
 * 
 */
int main(int argc, char** argv) {

 unsigned char z ;
 TRISB = 0;
 for (z=0;z<=255;z++)
      PORTB = z;

  while(1) ;
}
it worked but why
Code:
void main( void)
is not working?
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…