#include<reg51.h> #include<string.h> #include<stdio.h> #define lcd_data P1 sbit rs=P2^0; sbit rw=P2^1; sbit en=P2^2; unsigned char n[5]="hello"; unsigned char m[]="welcome rakesh"; void cmd_lcd(unsigned char); void write_lcd(char); void delay(unsigned int); void lcd_int() { cmd_lcd(0x38); cmd_lcd(0x0c); cmd_lcd(0x01); cmd_lcd(0x80); } void cmd_lcd(unsigned char x) { x=lcd_data; rs=0; rw=0; en=1; delay(50); en=0; }
void write_lcd(char s) {
s=lcd_data; rs=1; rw=0; en=1; delay(500); en=0; } void delay(unsigned int temp) { unsigned int i,j; for(i=0;i<255;i++); for(j=0;j<temp;j++); }
void main() { void lcd_int(); void write_lcd(n); void delay(500); void cmd_lcd(0x01); void delay(100); void write_lcd(m); void delay(100); }
this code shows following error: Build target 'Target 1' compiling lcdc04.c... LCDC04.C(50): error C161: 'n': formal parameter ignored Target not created
please help me in clearing this...
No, you don't have a problem in string display. You have a problem with basic understanding of the programming language you're writing in.
Look at the line that error message is about. You are the only one who can do that, because you managed to completely garble your source code by disregarding the posting instructions, so nobody else know which line to look at.
Look at that line. How does 'n' appear in that line? Then go back to your C textbook. Find out what's wrong with that line. If you can't, you either need a better book, or you need to go back several lessons and do them again, more slowly.
hey man.
you call write_lcd with n. n is the name of an array of characters. what c does is pass the address of the array. and your function write_lcd expects a single character. not an address to an array of characters.
it is very easy. practice and understand what I say. you will do fizzy.
you call write_lcd with n.
No, he doesn't.
look man. I am trying to help our friend. your bad does not help.
void main() { void lcd_int(); void write_lcd(n); // calling write_lcd with n void delay(500); void cmd_lcd(0x01); void delay(100); void write_lcd(m); void delay(100); }
I am trying to help our friend. Trying, and failing.
void write_lcd(n); // calling write_lcd with n
So you think. As does the OP. And you're both wrong.
he is calling it with n and I told him something what was wrong with that.
there is something else wrong. but what I told him is not wrong. if you cannot see it then you are not as clever as you think.
(Rakesh mate. look at the void.)
"he is calling it with n and I told him something what was wrong with that."
No he isn't and what you're telling him is wrong.
thank u boss, so how can I get a value there acoording to my source code logic? please answer
Haven't you already noticed that by your source code logic, you just can't get your values to print.
If you are interested in printing values, you could at least start to work through the list of problems I specified in an earlier post:
- reversed assigns - "nested" loops that aren't nested - void where no void should be - one string without zero-termination and one string with - how will the print code know how many characters to print? - interesting mix of arrays and characters - a function with empty () instead of (void) which might not be what was intended, depending on language selected - a main that terminates out into the unknown - a refusal to add comments or label the magic numbers used
how can I get a value there acoording to my source code logic?
you cant, the 'logic' is faulty
Step one must be to tidy up the listing a bit and fix some of the obvious errors.
#include<reg51.h> #include<string.h> #include<stdio.h> #define lcd_data P1 sbit rs=P2^0; sbit rw=P2^1; sbit en=P2^2; unsigned char n[]="hello"; unsigned char m[]="welcome rakesh"; void cmd_lcd(unsigned char); void write_lcd(char); void delay(unsigned int); void lcd_int(void) { cmd_lcd(0x38); cmd_lcd(0x0c); cmd_lcd(0x01); cmd_lcd(0x80); } void cmd_lcd(unsigned char x) { lcd_data=x; rs=0; rw=0; en=1; delay(50); en=0; } void write_lcd(char s) { lcd_data=s; rs=1; rw=0; en=1; delay(500); en=0; } void delay(unsigned int temp) { unsigned int i,j; for(i=0;i<255;i++) for(j=0;j<temp;j++) ; } void main() { unsigned int i; lcd_int(); for (i=0;n[i]!=0;++i) write_lcd(n[i]); delay(500); cmd_lcd(0x01); delay(100); for (i=0;m[i]!=0;++i) write_lcd(m[i]); delay(100); for (;;) ; }
Is this the second step: Spoon feed the OP by giving ready-to-use code.
Just trying to get the thread out of the kindergarten loop.
Although harmless, including string.h and stdio.h is not necessary.
Thanx to you, one more attempt to activate a brain to start may turn into a failure.
PS: We are not consultants and hence should not provide ready code. :)
"Just trying to get the thread out of the kindergarten loop."
But the big issue is if the OP should learn enough to pass the final exam or just get working code and then fail even harder on next exercise.
What isn't known is basically black magic. Copying code lines without understanding them results in programs like the one in the first post. Copying code lines from your post will just continue down that same route.
There really is a reason why teachers just don't hand out the final solution to problems and have the students duplicate it. It just fails so badly.