Ir ao conteúdo
  • Cadastre-se

Gustavo Andretto

Membro Pleno
  • Posts

    120
  • Cadastrado em

  • Última visita

Tudo que Gustavo Andretto postou

  1. #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct dados_t { char nome[32]; }Dados; int main() { FILE *arquivo; arquivo = fopen("test.txt", "w"); Dados* dados; dados = (Dados*)malloc(sizeof(Dados)); strcpy(dados->nome, "Hello"); fprintf(arquivo, " NOME: %s \n", dados->nome); // Vai escrever isso no .txt OU PELO MENOS DEVERIA free(dados); fclose(arquivo); return 0; } Poderia postar como está a sua struct Dados?
  2. @brookmj recomendo você a começar aprendendo a API do windows. Segue abaixo um exemplo retirado do site da Microsoft: // GT_HelloWorldWin32.cpp // compile with: /D_UNICODE /DUNICODE /DWIN32 /D_WINDOWS /c #include <windows.h> #include <stdlib.h> #include <string.h> #include <tchar.h> // Global variables // The main window class name. static TCHAR szWindowClass[] = _T("win32app"); // The string that appears in the application's title bar. static TCHAR szTitle[] = _T("Win32 Guided Tour Application"); HINSTANCE hInst; // Forward declarations of functions included in this code module: LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = NULL; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_APPLICATION)); if (!RegisterClassEx(&wcex)) { MessageBox(NULL, _T("Call to RegisterClassEx failed!"), _T("Win32 Guided Tour"), NULL); return 1; } hInst = hInstance; // Store instance handle in our global variable // The parameters to CreateWindow explained: // szWindowClass: the name of the application // szTitle: the text that appears in the title bar // WS_OVERLAPPEDWINDOW: the type of window to create // CW_USEDEFAULT, CW_USEDEFAULT: initial position (x, y) // 500, 100: initial size (width, length) // NULL: the parent of this window // NULL: this application does not have a menu bar // hInstance: the first parameter from WinMain // NULL: not used in this application HWND hWnd = CreateWindow( szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 500, 100, NULL, NULL, hInstance, NULL ); if (!hWnd) { MessageBox(NULL, _T("Call to CreateWindow failed!"), _T("Win32 Guided Tour"), NULL); return 1; } // The parameters to ShowWindow explained: // hWnd: the value returned from CreateWindow // nCmdShow: the fourth parameter from WinMain ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // Main message loop: MSG msg; while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); } return (int) msg.wParam; } // // FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM) // // PURPOSE: Processes messages for the main window. // // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; TCHAR greeting[] = _T("Hello, World!"); switch (message) { case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // Here your application is laid out. // For this introduction, we just print out "Hello, World!" // in the top left corner. TextOut(hdc, 5, 5, greeting, _tcslen(greeting)); // End application-specific layout section. EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); break; } return 0; } caso tenha alguma dúvida eu posso te ajudar sobre a winapi. obs: recomendo também este site: http://zetcode.com/gui/winapi/introduction/
  3. Aprenda C++ ou C# antes de aprender interface gráfica. Você precisará ter noção de orientação a objetos pra trabalhar com interface gráfica.
  4. acabei comprando a asus rog strix mesmo, eu estava esperando a xfx 480 gtr mas pelo jeito quando essas placa custom da amd chegar no brasil não vai ser mais novidade =/ valeu ai.
  5. E ai pessoal, estou querendo comprar uma placa de vídeo nova porém ainda estou em dúvida em qual escolher. estou em duvida entre estas placas: NVIDIA: Placa de Vídeo VGA ASUS GTX 1060 6GB Strix Gaming STRIX-GTX1060 Placa de Vídeo VGA GigaByte GTX 1060 G1 Gaming 6GB AMD: Placa de Vídeo VGA Sapphire Radeon RX 480 8G GDDR5 1342MHz NITRO+
  6. Pra calcular o quadrado da soma/diferença você pode fazer uma função que retorne o calculo. // Quadrado da soma; int sqSum(int a, int b) { return (a + b) * (a + b); } // Quadrado da diferença; int sqDiff(int a, int b) { return (a - b) * (a - b); }
  7. pra mostras mais de uma posição é só colocar o printf dentro do laço de busca: for(int lin=0;lin<m;lin++){ for(int col=0;col<m;col++){ if(x == v[lin][col]){ printf("numero encontrado em : %d %d",lin,col); z++; // usarei o z pra saber quantos numeros foram encontrados; } } } if(z == 0){ // caso z seja 0, nenhum numero foi encontrado; printf("Nao encontrado"); } int main() { const int TAM = 20; int lin, col, busca, z; int v[TAM][TAM]; // Insere os números na matriz; for (lin = 0; lin < TAM; lin++) { for (col = 0; col < TAM; col++) { //printf("Informe [%d][%d]:", lin+1, col+1); //scanf("%d", &v[lin][col]); scanf_s("%d", &v[lin][col]); } } printf("\nInforme um numero para busca: "); //scanf("%d", &busca); scanf_s("%d", &busca); // Procura um número na matriz; z = 0; for (int lin = 0; lin < TAM; lin++) { for (int col = 0; col < TAM; col++) { if (busca == v[lin][col]) { printf("Numero encontrado em: [%d] [%d]\n", lin, col); z++; // Incrementa pra saber quantos números foram encontrados; } } } if (z == 0) printf("Nenhum numero encontrado\n"); system("PAUSE"); return (0); }
  8. Segue abaixo: int numero; do { printf("Informe um numero\n"); scanf_s("%d", &numero); // multiplica o valor do numero por 3 a cada leitura; numero = (numero * 3); // Imprime o resultado; printf("Numero: %d\n", numero); } while (numero < 100); // sai do laço quando numero for maior que 100
  9. esse atlhon é bem fraquinho, com o i5 você vai conseguir abrir tranquilo(pelo menos eu acho rsrs). no meu eu abria 5 maquinas pra deixar logado em alguns jogos(mu, aika) e era tranquilo.
  10. Olá @Phelipe Àvila , Faça o seguinte, clique com o botão direito sobre o dispositivo, selecione propriedades, vá na aba Driver, clique em desinstalar. Depois instale novamente o driver de áudio(de preferência a versão mais atualizada).
  11. Eu já tive uma B85M, dava o mesmo problema. Pra resolver, clique com o botão direito no alto falante do lado do relógio, selecione dispositivos de reprodução e desative todos os NVIDIA HDMI Output.
  12. fiz um aqui pra você brinca o arquivo descompactado tem 1,19gb loremipsum.7z
  13. Olá @Alpha Informatica , tem sim, recomendo este programa https://rufus.akeo.ie/?locale=pt_BR
  14. Tente reinstalar as libraries do visual c++, são varias você vai ter que instalar um por um. https://support.microsoft.com/en-us/kb/2977003 Tem vários links ai, porém, os que interessam à você são os que estão escrito: Microsoft Visual C++ Redistributable Packages for Visual Studio. Obs: se não me engano você fez o post na área errada rsrs.
  15. @Lucas Martins Leite remova a linha memset(Motor, 0, sizeof(Motor)); e adicione: Motor[0].Status = 0; // Status de Motor A; Motor[1].Status = 0; // Status de Motor B; Motor[2].Status = 0; // Status de Motor C;
  16. Boa tarde! De acordo com minha interpretação deste exercício, segue minha solução: #include <iostream> typedef struct { int Potencia; int Status; }Motor_t; int main() { Motor_t Motor[3]; // Quantidade de motores; memset(Motor, 0, sizeof(Motor)); // Limpa os dados em Motor; Motor[0].Potencia = 30; // Motor A; Motor[1].Potencia = 50; // Motor B; Motor[2].Potencia = 70; // Motor C; int DemandaAtual = 0, DemandaMax = 100; // Demanda Atual e Demanda Máxima; // Motor A std::cout << "Digite (0) ou (1) para Desligar/Ligar Motor (A): "; do std::cin >> Motor[0].Status; while (Motor[0].Status > 1 || Motor[0].Status < 0); // Rodará o laço enquanto Motor (A) for diferente de 0 ou 1; // Caso Motor A esteja ligado if (Motor[0].Status) { DemandaAtual = Motor[0].Potencia; // atribui potencia de motor (A) à DemandaAtual; //std::cout << "\nMotor (A) ligado" << std::endl; //std::cout << "\nDemanda Atual: " << DemandaAtual << std::endl; } // Motor B std::cout << "Digite (0) ou (1) para Desligar/Ligar Motor (B): "; do std::cin >> Motor[1].Status; while (Motor[1].Status > 1 || Motor[1].Status < 0); if (Motor[1].Status) { DemandaAtual += Motor[1].Potencia; // Valor de DemandaAtual é atribuido à soma de seu valor atual mais potência de motor (B); //std::cout << "\nMotor (B) ligado" << std::endl; //std::cout << "\nDemanda Atual: " << DemandaAtual << std::endl; } // Motor C std::cout << "Digite (0) ou (1) para Desligar/Ligar Motor (C): "; do std::cin >> Motor[2].Status; while (Motor[2].Status > 1 || Motor[2].Status < 0); if (Motor[2].Status) { DemandaAtual += Motor[2].Potencia; // Valor de DemandaAtual é atribuido à soma de seu valor atual com potência de motor (C); //std::cout << "\nMotor (C) ligado" << std::endl; //std::cout << "\nDemanda Atual: " << DemandaAtual << std::endl; } // Verifica se DemandaAtual excedeu o valor de DemandaMax; int i = 0; while (DemandaAtual > DemandaMax) { Motor[i].Status = 0; // Desliga o motor de menor valor; std::cout << "\nDemanda Atual excedeu o limite(" << DemandaAtual << "-" << DemandaMax << "), motor " << (char)(0x41+i) << " sera desligado." << std::endl; DemandaAtual -= Motor[i].Potencia; i++; } // Imprime na tela o status dos motores: if (Motor[0].Status) std::cout << "\nMotor (A) ligado" << std::endl; else std::cout << "\nMotor (A) desligado" << std::endl; if (Motor[1].Status) std::cout << "\nMotor (B) ligado" << std::endl; else std::cout << "\nMotor (B) desligado" << std::endl; if (Motor[2].Status) std::cout << "\nMotor (B) ligado" << std::endl; else std::cout << "\nMotor (B) desligado" << std::endl; std::cout << "\nDemanda Atual: " << DemandaAtual << std::endl; system("PAUSE"); return 0; }
  17. Olá, você pode sim utilizar o notebook para ligar um servidor de minecraft, porém, deixar o notebook ligado 24h na tomada pode acabar queimando sua fonte interna.
  18. Olá @Rgustavo , Faça o seguinte: B[tam-i] = A; sendo tam o tamanho do vetor e i o número de iteração, segue o código: #include <stdio.h> #include <stdlib.h> int main() { int i; int A[10], B[10]; for (i = 0; i < 10; i++) { printf("Informe um numero %i, para Vetor A = ", (i+1)); //scanf("%i", &A); scanf_s("%i", &A[i]); B[9-i] = A[i]; } return 0; }
  19. Olá, segue minha solução: #include <stdio.h> #include <stdlib.h> #define TAM 20 // Define a quantidade para cadastro; typedef struct { char Nome[32]; float Nota[4]; float Media; }Aluno_t; int main() { int i, j, posMaior, posMenor; float Maior, Menor; Aluno_t Aluno[20]; // Cadastra os alunos e suas notas na estrutura; for (i = 0; i < TAM; i++) { printf("[%d]Nome do Aluno: ", i+1); //scanf("%s", Aluno[i].Nome); scanf_s("%s", Aluno[i].Nome, (int)_countof(Aluno[i].Nome)); // Insere as notas; for (j = 0; j < 4; j++) { printf("Nota %d: ", j+1); scanf_s("%f", &Aluno[i].Nota[j]); } // Calcula média do aluno[i]; Aluno[i].Media = (Aluno[i].Nota[0] + Aluno[i].Nota[1] + Aluno[i].Nota[2] + Aluno[i].Nota[3]) / 4; system("cls"); } // Verifica qual teve a maior e qual teve a menor média; Maior = 0; // inicializa Maior como zero; Menor = Aluno[0].Media; // inicializa Menor como primeiro elemento; for (i = 0; i < TAM; i++) { // Verifica maior média; if (Aluno[i].Media > Maior) { posMaior = i; // Posição do maior valor; Maior = Aluno[i].Media; // Maior passa a ser Aluno[i].Media; } // Verifica menor média; if (Aluno[i].Media < Menor) { posMenor = i; Menor = Aluno[i].Media; } } // Imprime na tela todos os alunos e suas medias; for (i = 0; i < TAM; i++) printf("Aluno %s, media: %0.1f\n", Aluno[i].Nome, Aluno[i].Media); printf("[Maior Media] Aluno: %s, media %0.1f\n", Aluno[posMaior].Nome, Aluno[posMaior].Media); printf("[Menor Media] Aluno: %s, media %0.1f\n", Aluno[posMenor].Nome, Aluno[posMenor].Media); system("PAUSE"); //getchar(); return 0; }
  20. eu tenho a h97-d3h e recomendo, uso ela com um i5 4440.
  21. @1freakday Opa obrigado pela dica, acabei de implementa-la no código. Quanto a: eu consegui resolver fazendo um memcpy da struct para um vetor de char. Segue abaixo o código completo: #include <iostream> #include <fstream> #define QTD 32 typedef struct { char Test[16]; int Value; int Secret; }test_t; using namespace std; unsigned char EncDec_Key[32] = { 0x10, 0xD5, 0xCD, 0x0E, 0x4C, 0x4D, 0x31, 0xE1, 0x8A, 0x6F, 0xC6, 0x75, 0x7B, 0x2C, 0xD9, 0xDD, 0xB6, 0xAA, 0x3F, 0x42, 0xDE, 0xDB, 0x2D, 0xB2, 0x36, 0xCC, 0xDE, 0xFC, 0x84, 0x78, 0x2D, 0x32 }; void EncDec(char* Source, int Size) { int i, j; for (i = 0; i < Size; i++) { for (j = 0; j < sizeof(EncDec_Key); j++) *Source ^= (EncDec_Key[j] * (i + 1)); // Para cada elemento do ponteiro, é feito uma atribuição XOR com o resultado da expressão; Source++; // Incrementa para apontar para o próximo elemento do ponteiro; } } void preencher(test_t* tst) { for (int i = 0; i < QTD; i++) { strcpy_s(tst->Test, "Teste"); tst->Secret = 2016; tst->Value = 22; tst++; } } int main() { test_t Test[QTD]; test_t Test_Dec[QTD]; char* buffer = new char[sizeof(Test)]; memset(Test, 0, sizeof(Test)); memset(Test_Dec, 0, sizeof(Test)); memset(buffer, 0, sizeof(Test)); // Grava um valor qualquer em Test; preencher(Test); // Copia todos os dados de Test para buffer; memcpy_s(buffer, sizeof(Test), Test, sizeof(Test)); // Cifra os dados em buffer; EncDec(buffer, sizeof(Test)); // Grava em um arquivo os dados de buffer; ofstream ofile; ofile.open("Teste.bin", ios::binary); ofile.write((const char*)buffer, sizeof(Test)); ofile.close(); // Abre para leitura e grava os dados em buffer ifstream ifile; ifile.open("Teste.bin", ios::binary); ifile.read(buffer, sizeof(Test)); ifile.close(); // Decifra os dados em buffer EncDec(buffer, sizeof(Test)); // Copia todos dados de buffer para Test_Dec; memcpy_s(Test_Dec, sizeof(Test), buffer, sizeof(Test)); delete[] buffer; // Grava em um arquivo os dados de Test_Dec; ofile.open("Teste_Dec.bin", ios::binary); ofile.write((const char*)Test_Dec, sizeof(Test)); ofile.close(); return 0; }
  22. @1freakday Obrigado por responder! Depois de algumas horas panguando, consegui fazer um código que cifra e decifra. Porém, só consigo encriptar texto, preciso encriptar um vetor de estrutura e salvar em um arquivo, Código para cifrar; void Enc(unsigned char* Source, int Size, int Key) { int i; for (i = 0; i < Size; i++) // Para cada elemento do ponteiro é feito uma Source[i] += (Key * (i + 1)); // atribuição por adição com o resultado a expressão. } Código para decifrar; void Dec(unsigned char* Source, int Size, int Key) { int i; for (i = 0; i < Size; i++) Source[i] -= (Key * (i + 1)); // Para decifrar basta aplicar a operação inversa usada pra encriptar. }
  23. @iuri19 boa noite, Eu não recomendo esse FX 8320E, da muito gargalo, se puder gastar R$200 a mais, compre um i5 da intel.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!