duartecarvalhoo Posted August 22, 2010 at 05:21 PM Report #344034 Posted August 22, 2010 at 05:21 PM Boas, Estou a criar um género de aplicação que facilite ao utilizador normal do windows 7 a visualização de informações sobre a sua ligação à Internet e dados wireless, usando comandos do género netsh, ipconfig e etc. Até aí tudo bem usei switch pra permitir escolher e tudo e agora queria que apesar de o utilizador escolher a opção 1 poder voltar ao menu de escolha vezes sem conta e escolher outra opção ou ate mesmo repetir a que fez anteriormente. obrigado desde ja , cumps
bruno1234 Posted August 22, 2010 at 05:26 PM Report #344035 Posted August 22, 2010 at 05:26 PM mete isso num while (true). Não te esqueças de por também uma opção para sair da aplicação. Matraquilhos para Android. Gratuito na Play Store. https://play.google.com/store/apps/details?id=pt.bca.matraquilhos
duartecarvalhoo Posted August 22, 2010 at 05:29 PM Author Report #344039 Posted August 22, 2010 at 05:29 PM O que tenho é isto, tem a opção de saída que gostava que estivesse presente em todas as opções bem como voltar atras ao menu. #include <stdio.h> #include <stdlib.h> int main() { int i; do { printf("\n"); printf("Aplicacao dedicada de internet para windows 7\n"); printf("\n"); printf("\n"); printf("\n"); printf ("Escolha a funcao a utilizar e clique ENTER\n"); printf("\n"); printf("\n"); printf ("\t\t(1)Netsh redes wireless\n"); printf("\n"); printf ("\t\t(2)IPconfig\n"); printf("\n"); printf ("\t\t(3)Netstat\n"); printf("\n"); printf ("\t\t(4)Flush DNS\n"); printf("\n"); printf ("\t\t(5)Renovar IP\n"); printf("\n"); printf ("\t\t(6)Sequencia de todas as funcoes\n"); printf("\n"); printf ("\t\t(0)Sair\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); scanf("%d", &i); } while ((i<0)||(i>6)); switch (i) { case 1: printf ("\t\tVoce escolheu Netsh redes wireless.\n");printf("\n");printf("\n"); system("netsh wlan show networks mode=bssid"); break; case 2: printf ("\t\tVoce escolheu IPconfig.\n");printf("\n");printf("\n"); system("ipconfig /all"); break; case 3: printf ("\t\tVoce escolheu Netstat.\n");printf("\n");printf("\n"); system("netstat -a"); break; case 4: printf ("\t\tVoce escolheu Flush DNS.\n");printf("\n");printf("\n"); system("ipconfig /flushdns"); break; case 5: printf ("\t\tVoce escolheu Renovar IP.\n");printf("\n");printf("\n"); system("ipconfig /renew"); break; case 0: printf ("\t\tVoce escolheu Sair.\n");printf("\n");printf("\n"); system("exit"); break; case 6: printf ("\t\tVoce escolheu a Sequencia de todas as funcoes.\n");printf("\n");printf("\n"); system("pause");printf("\n"); system("netsh wlan show networks mode=bssid");printf("\n"); system("pause");printf("\n"); system("ipconfig /all");printf("\n"); system("pause");printf("\n"); system("netstat -a");printf("\n"); system("ipconfig /flushdns");printf("\n"); system("pause");printf("\n"); system("ipconfig /renew");printf("\n"); system("pause"); break; } system("pause"); return 0; } HELP ??
Guest Posted August 22, 2010 at 05:47 PM Report #344041 Posted August 22, 2010 at 05:47 PM mete isso tudo dentro de um do...while, se não só ira executar 1 vez o menu
duartecarvalhoo Posted August 22, 2010 at 05:49 PM Author Report #344042 Posted August 22, 2010 at 05:49 PM ponho o qe dentro do while?
Guest Posted August 22, 2010 at 05:51 PM Report #344043 Posted August 22, 2010 at 05:51 PM o switch EDIT: Esqueci me de te dizer para meteres no while while(1) para ser um loop infinito, depois metes uma opção no menu com exit
Localhost Posted August 22, 2010 at 05:56 PM Report #344045 Posted August 22, 2010 at 05:56 PM Atenção aos títulos dos tópicos.. here since 2009
duartecarvalhoo Posted August 22, 2010 at 05:58 PM Author Report #344046 Posted August 22, 2010 at 05:58 PM com while(1); no fim ele acaba a opçao e pede um numero meto por exemplo 1 e nada acontece....
Guest Posted August 22, 2010 at 05:59 PM Report #344047 Posted August 22, 2010 at 05:59 PM Não Percebi, podes postar o output?
Guest user14912 Posted August 22, 2010 at 06:00 PM Report #344048 Posted August 22, 2010 at 06:00 PM Atenção aos títulos dos tópicos.. Realmente.. nem reparei que era um tópico a pedir ajuda, muito menos um tópico de C
BELGA Posted August 22, 2010 at 06:01 PM Report #344049 Posted August 22, 2010 at 06:01 PM como já te disseram basta meteres o código dentro de um ciclo infinito while ou do/while... do{ //Codigo com o menu e switch.... if (SAIR) break; }while(1); valterc.pt.vc
duartecarvalhoo Posted August 22, 2010 at 06:04 PM Author Report #344051 Posted August 22, 2010 at 06:04 PM Não avança depois de me pedir o numero aseguir a funçao #include <stdio.h> #include <stdlib.h> int main() { int i; do { printf("\n"); printf("Aplicacao dedicada de internet para windows 7\n"); printf("\n"); printf("\n"); printf("\n"); printf ("Escolha a funcao a utilizar e clique ENTER\n"); printf("\n"); printf("\n"); printf ("\t\t(1)Netsh redes wireless\n"); printf("\n"); printf ("\t\t(2)IPconfig\n"); printf("\n"); printf ("\t\t(3)Netstat\n"); printf("\n"); printf ("\t\t(4)Flush DNS\n"); printf("\n"); printf ("\t\t(5)Renovar IP\n"); printf("\n"); printf ("\t\t(6)Sequencia de todas as funcoes\n"); printf("\n"); printf ("\t\t(0)Sair\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); scanf("%d", &i); } while ((i<0)||(i>6)); switch (i) { case 1: printf ("\t\tVoce escolheu Netsh redes wireless.\n");printf("\n");printf("\n"); system("netsh wlan show networks mode=bssid");scanf("%d", &i); break; case 2: printf ("\t\tVoce escolheu IPconfig.\n");printf("\n");printf("\n"); system("ipconfig /all");scanf("%d", &i); break; case 3: printf ("\t\tVoce escolheu Netstat.\n");printf("\n");printf("\n"); system("netstat -a");scanf("%d", &i); break; case 4: printf ("\t\tVoce escolheu Flush DNS.\n");printf("\n");printf("\n"); system("ipconfig /flushdns");scanf("%d", &i); break; case 5: printf ("\t\tVoce escolheu Renovar IP.\n");printf("\n");printf("\n"); system("ipconfig /renew");scanf("%d", &i); break; case 0: printf ("\t\tVoce escolheu Sair.\n");printf("\n");printf("\n"); system("exit");scanf("%d", &i); break; case 6: printf ("\t\tVoce escolheu a Sequencia de todas as funcoes.\n");printf("\n");printf("\n"); system("pause");printf("\n"); system("netsh wlan show networks mode=bssid");printf("\n"); system("pause");printf("\n"); system("ipconfig /all");printf("\n"); system("pause");printf("\n"); system("netstat -a");printf("\n"); system("ipconfig /flushdns");printf("\n"); system("pause");printf("\n"); system("ipconfig /renew");printf("\n"); scanf("%d", &i); break; if (0) break; }while(1); system("pause"); return 0; }
Guest Posted August 22, 2010 at 06:05 PM Report #344053 Posted August 22, 2010 at 06:05 PM Poderá não são 2 do...whiles e sim um
Guest Posted August 22, 2010 at 06:10 PM Report #344055 Posted August 22, 2010 at 06:10 PM #include <stdio.h> #include <stdlib.h> int main() { int i; do { printf("\n"); printf("Aplicacao dedicada de internet para windows 7\n"); printf("\n"); printf("\n"); printf("\n"); printf ("Escolha a funcao a utilizar e clique ENTER\n"); printf("\n"); printf("\n"); printf ("\t\t(1)Netsh redes wireless\n"); printf("\n"); printf ("\t\t(2)IPconfig\n"); printf("\n"); printf ("\t\t(3)Netstat\n"); printf("\n"); printf ("\t\t(4)Flush DNS\n"); printf("\n"); printf ("\t\t(5)Renovar IP\n"); printf("\n"); printf ("\t\t(6)Sequencia de todas as funcoes\n"); printf("\n"); printf ("\t\t(0)Sair\n"); printf("\n"); printf("\n"); printf("\n"); printf("\n"); scanf("%d", &i); switch (i) { case 1: printf ("\t\tVoce escolheu Netsh redes wireless.\n");printf("\n");printf("\n"); system("netsh wlan show networks mode=bssid"); break; case 2: printf ("\t\tVoce escolheu IPconfig.\n");printf("\n");printf("\n"); system("ipconfig /all"); break; case 3: printf ("\t\tVoce escolheu Netstat.\n");printf("\n");printf("\n"); system("netstat -a"); break; case 4: printf ("\t\tVoce escolheu Flush DNS.\n");printf("\n");printf("\n"); system("ipconfig /flushdns"); break; case 5: printf ("\t\tVoce escolheu Renovar IP.\n");printf("\n");printf("\n"); system("ipconfig /renew"); break; case 0: printf ("\t\tVoce escolheu Sair.\n");printf("\n");printf("\n"); system("exit"); break; case 6: printf ("\t\tVoce escolheu a Sequencia de todas as funcoes.\n");printf("\n");printf("\n"); system("pause");printf("\n"); system("netsh wlan show networks mode=bssid");printf("\n"); system("pause");printf("\n"); system("ipconfig /all");printf("\n"); system("pause");printf("\n"); system("netstat -a");printf("\n"); system("ipconfig /flushdns");printf("\n"); system("pause");printf("\n"); system("ipconfig /renew");printf("\n"); system("pause"); break; } }while(1); system("pause"); return 0; } Devo dizer que não testei
Localhost Posted August 22, 2010 at 06:18 PM Report #344058 Posted August 22, 2010 at 06:18 PM Imaginando que a opção de saída é -1 podemos fazer assim: while( esc != -1 ); here since 2009
duartecarvalhoo Posted August 22, 2010 at 06:20 PM Author Report #344062 Posted August 22, 2010 at 06:20 PM obrigado a todos funcionou 😄
duartecarvalhoo Posted August 22, 2010 at 06:22 PM Author Report #344064 Posted August 22, 2010 at 06:22 PM a saida e qe nao esta a funcionar e a opção dada pelo localhost nao funciona devido a algum erro qe nao encontro
Guest Posted August 22, 2010 at 06:28 PM Report #344065 Posted August 22, 2010 at 06:28 PM mudaste a variavel esc do exemplo?
duartecarvalhoo Posted August 22, 2010 at 06:30 PM Author Report #344067 Posted August 22, 2010 at 06:30 PM nao devo mudar apenas o -1 pra 0?
Guest Posted August 22, 2010 at 06:32 PM Report #344070 Posted August 22, 2010 at 06:32 PM Se for esse o valor que deste para a opção Sair, sim claro, precisas também de mudar o esc para a variável que contem o valor
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now