| | |
pls heeeeeeeeelp its urgent.
![]() |
•
•
Join Date: Oct 2004
Posts: 2
Reputation:
Solved Threads: 0
Hi
I got one assignment to submit within 2 days.I am suppose to build scanner(lexicle analyser) in c,which will take input from standard input stream and print its class.
for example if I input + it will displya "plus",- "minus"
I have to run this program in unix environment.
program will have main function which will accept character from input stream
and call scanner function to get its type.
I have to use getchar(),putcar() and ungetc() functions for this.
I dont know how to use unggetc function withh stdin(standard input).
there will be buffer which will be difeined globally and can be accessed by all the functions.I also want to know how to compile the and run the file in unix enviornment.
I have lost thhe touch with 'c'.Didntdo it from last 2 years.
code will be somewhat like this
main()
{
char msg [][]={"plus","minus"};....(dont know howto use this,gives error char const too long)int code;
char next;
next=getchar();
putchar(next);
ungetc(next);
code=scanner();
while(code!=EOF)
{
print msg;
print buffer;
code=scanner();
}
int scanner()
{
int code;
char next;
if(next=='+')
{
code=get_plus();
}elseif(next=='-')
{code=get_minus();}
return code;
}
I got one assignment to submit within 2 days.I am suppose to build scanner(lexicle analyser) in c,which will take input from standard input stream and print its class.
for example if I input + it will displya "plus",- "minus"
I have to run this program in unix environment.
program will have main function which will accept character from input stream
and call scanner function to get its type.
I have to use getchar(),putcar() and ungetc() functions for this.
I dont know how to use unggetc function withh stdin(standard input).
there will be buffer which will be difeined globally and can be accessed by all the functions.I also want to know how to compile the and run the file in unix enviornment.
I have lost thhe touch with 'c'.Didntdo it from last 2 years.
code will be somewhat like this
main()
{
char msg [][]={"plus","minus"};....(dont know howto use this,gives error char const too long)int code;
char next;
next=getchar();
putchar(next);
ungetc(next);
code=scanner();
while(code!=EOF)
{
print msg;
print buffer;
code=scanner();
}
int scanner()
{
int code;
char next;
if(next=='+')
{
code=get_plus();
}elseif(next=='-')
{code=get_minus();}
return code;
}
Nope, sorry I dont know.
Need Website Work... PM Me or EMail Me at mdstreetsoulja@gmail.com ... I am AVAILABLE!
Please don't name future threads something like this. We don't really care if your issue is urgent to you or not. I don't mean to be rude to you, but you stating your issue is urgent is rude to the forum, and the other members that have been waiting for help.
If you'll PM me a more appropriate title, I'll change it to something else. But again, please don't be so rude in the future.
If you'll PM me a more appropriate title, I'll change it to something else. But again, please don't be so rude in the future.
Alex Cavnar, aka alc6379
your char msg [][] is an array of arrays of char, but the way you initialize it is as an array of char*'s, so how about:
char *msg[] = {"plus","minus"};
Your scanner routine never sets 'next' to anything, so it would be random. Maybe you meant it to be a parameter?
There's a bunch of other stuff, but this is pseudocode pretty devoid of design, so it's hard to critique.
char *msg[] = {"plus","minus"};
Your scanner routine never sets 'next' to anything, so it would be random. Maybe you meant it to be a parameter?
There's a bunch of other stuff, but this is pseudocode pretty devoid of design, so it's hard to critique.
![]() |
Similar Threads
- Data Flow Diagram (Database Design)
- C++ Prog..........urgent (C++)
- how to jam the text boxes (VB.NET)
- Mouse Problem - Help needed urgently (Viruses, Spyware and other Nasties)
Other Threads in the C Forum
- Previous Thread: Array problem
- Next Thread: Problems of looping in saving to a text file
| Thread Tools | Search this Thread |
* adobe ansi api array arrays binarysearch calculate centimeter char character cm convert copyanyfile copypdffile cprogramme createcopyoffile createprocess() csyntax directory dynamic feet fflush file floatingpointvalidation fork forloop frequency getlasterror getlogicaldrivestrin givemetehcodez global graphics gtkgcurlcompiling gtkwinlinux hacking highest homework i/o inches incrementoperators intmain() iso km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. lowest match matrix microsoft mqqueue mysql oddnumber odf open opendocumentformat openwebfoundation pattern pdf performance posix power program programming pyramidusingturboccodes read recursion recv recvblocked repetition reversing scanf scheduling segmentationfault send shape single socketprograming socketprogramming stack standard strchr string suggestions test unix urboc user variable voidmain() whythiscodecausesegmentationfault win32api windows.h windowsapi






