![]() |
Help with goto statement
This is my main program
Code:
#include<stdio.h>Code:
#include<stdio.h>Please look at the menu and enter the corresponding choice 1.Simple Port Scan : 2.Check you device name,net address and subnet mask 3.Let's Sniff 1 enter the ip127.0.0.1 22 is open 25 is open 111 is open 631 is open now exit scanner Do you wish to continue ??exit //end of output The problem is after do you wish to continue it does not wait for an input and just exits.This problem is only there when I choose option 1 that is simple port scan otherwise on choosing any other option the program keeps workin fine.Any clue or suggestion would be great.Thanks |
Re: Help with goto statement
do these changes in your code
========================= Code:
............... |
Re: Help with goto statement
give me the other two files "dev_net.h" and "sniff.h".
It will help me to find the problem. |
Re: Help with goto statement
Its not the problem with the goto , its problem with the buffer . I made some small changes in your program and now its working fine.Just close the socket fd ( net ) .
Code:
#include<stdio.h> |
Re: Help with goto statement
Quote:
|
Re: Help with goto statement
Ok lemme try that karthigayan...
|
Re: Help with goto statement
Ok could you also tell me why use getchar() and than scanf in next line.getchar() takes input than what is scanf for
|
Re: Help with goto statement
Code:
if((new=connect(net,(struct sockaddr *)&sa,sizeof(sa)))>=0) |
Re: Help with goto statement
Its to avoid the buffer problem.Some times the buffer may contain '\n'.Because the previous scanf will not consider the '\n' which you gave after typing the input.So when the next scanf (Here for ans ) will look on the '\n' and consider that the input for ans is available , so it will process with that .To avoid that I used getchar() ,so now the getchar will get the '\n',so the scanf can get the fresh input from the user.
I hope you understand. |
Re: Help with goto statement
Made the changes in my code.Now it is taking the input but second time when you select 1.It simply exits.Same problem in your code karthigayan.
output Please look at the menu and enter the corresponding choice 1.Simple Port Scan : 2.Check you device name,net address and subnet mask 3.Let's Sniff 1 Enter the ip : 127.0.0.1 22 is open 25 is open 111 is open 631 is open now exit scanner Do you wish to continue : y Please look at the menu and enter the corresponding choice 1.Simple Port Scan : 2.Check you device name,net address and subnet mask 3.Let's Sniff 1 Enter the ip : 209.85.231.104 now exit scanner Do you wish to continue : n ---------------------------------------------------------------------------------------------------------------- Second time it doesn't do anything .Something wrong in the scanner function ? |
| All times are GMT +5.5. The time now is 05:06. |