#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...
Are you sure you understand the direction of an assign, i.e that the assign is made to the object on the left side of the "=" character?
Exactly what do you think happens with your input parameter, when you directly overwrite it? Does it seem well used?
By the way - did you specifically dislike following the posting instructions and tag your source code according to the info available directly above the message input box?
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.
Dan,
I'm very confused with what you say.
You said that what Jameel was telling the OP was wrong, but then you provide a link which actually supports what he said.
That is:
Passing the wrong type of parameter. Jameel said "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." Lint reports "Type mismatch". Not totally correct, but a reasonable start.
Incorrect position of void. Jameel said "(Rakesh mate. look at the void.)". We can only guess how much was understood with that, but along the right lines.
And yes, I acknowledge that there are other errors/warnings that Lint picked up.
Please don't fall into that distasteful habit that certain other posters have on this forum.
Inside main(), 'void' made the line a function declaration, not a call as claimed.
"You said that what Jameel was telling the OP was wrong, but then you provide a link which actually supports what he said."
No, Jameel is stuck on function invocation; that is, calling. There is no "calling" being performed. The code's incorrectness hasn't even allowed lint to complain about a function call (yet).
Quite interesting that people refuse to read code before "knowing" what the code does. And people who refuse to read compiler error messages and look in text books to verify the assumptions about how code is expected to be written.
First comes the OP with some "very interesting" code containing quite a number of errors (probably just a partial list - it's hard to read when the formatting is junked because of missing tags in the 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
Then come a "helper" who haven't made sure he understands the line he is commenting about. And doesn't spend a bit of extra time checking it again when told he is wrong.
But the two things that Jameel mentioned are not wrong per se. He mentioned two things that are genuine faults. Ok, he missed some others and really stated those two in the wrong order, but the long and the short of it is that he just got knocked big time for stating faults.
It seems that this forum does not permit beginners helping beginners.
Quite extraordinary.
Judging by the quality of the code and advice, it is quite possible that one or both are consultants.
But the line he discussed wasn't a function call - so his description of calling the function with wrong data just couldn't be correct. A function that never gets called will never output anything.