User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 391,944 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,889 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
Views: 1699 | Replies: 5
Reply
Join Date: Oct 2004
Posts: 2
Reputation: vrush is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
vrush vrush is offline Offline
Newbie Poster

pls heeeeeeeeelp its urgent.

  #1  
Oct 29th, 2004
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;
}
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2004
Location: Delaware, USA
Posts: 417
Reputation: Young Teck 06 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Young Teck 06's Avatar
Young Teck 06 Young Teck 06 is offline Offline
Street Game CEO

Re: pls heeeeeeeeelp its urgent.

  #2  
Oct 29th, 2004
Nope, sorry I dont know.
Need Website Work... PM Me or EMail Me at mdstreetsoulja@gmail.com ... I am AVAILABLE!
Reply With Quote  
Join Date: Dec 2003
Location: Nashville, TN
Posts: 2,333
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Rep Power: 11
Solved Threads: 101
Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: pls heeeeeeeeelp its urgent.

  #3  
Oct 29th, 2004
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.
Alex Cavnar, aka alc6379
Reply With Quote  
Join Date: Jun 2004
Location: Marin, CA, USA
Posts: 434
Reputation: Chainsaw is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 10
Chainsaw's Avatar
Chainsaw Chainsaw is offline Offline
Unprevaricator

Re: pls heeeeeeeeelp its urgent.

  #4  
Oct 29th, 2004
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.
Reply With Quote  
Join Date: Sep 2004
Posts: 6,019
Reputation: Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of 
Rep Power: 26
Solved Threads: 414
Super Moderator
Narue's Avatar
Narue Narue is online now Online
Expert Meanie

Re: pls heeeeeeeeelp its urgent.

  #5  
Oct 29th, 2004
>so it's hard to critique
A critique is not difficult at all: "Your code is crap, post something that actually uses C--not whatever it is you think is C--and we'll help." Simple.
Member of: Beautiful Code Club.
Reply With Quote  
Join Date: Oct 2004
Posts: 2
Reputation: vrush is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
vrush vrush is offline Offline
Newbie Poster

Re: pls heeeeeeeeelp

  #6  
Oct 29th, 2004
Thanks Chainsaw I will try declaring it that way.and sorry alc6379.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 8:49 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC