Jump to content
Fórum Script Brasil
  • 0
Sign in to follow this  
medicisolucoes

Leio arquivo mas não consigo comparar com IF

Question

Pessoal bom dia. Estou reaprendendo a programar, depois de um acidente que me fez perder muita coisa, inclusive memoria.

Fiz um programa que pega um valor que ta num arquivo e armazena numa variavel, mas não consigo comparar pra ver se é igual a alguma palavra que tenho. podem me ajudar?

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
using namespace std;

int main()
{
  FILE *arq;
  char Linha[20]={ };
  char ch;
  char *result;
  int i;
  system("powershell \"Get-CimInstance -ClassName Win32_ComputerSystem | foreach { $_.Manufacturer }\" > arqsnipe.txt");
  arq = fopen("arqsnipe.txt", "rt");
  result = fgets(Linha, 20, arq);
  for (i=0;i<=19;i++){
    printf("%c - %i\n",Linha, i);
  }
  fclose(arq);

  if (Linha == "Hewlett-Packard"){
    printf("\nOpcao 1\n");
  }else{
    printf("\nOpcao 2\n");
  }
}

image.png.2848a31d255f5a19de5fe84b387a98bf.png

Edited by medicisolucoes
Acrescimo de Resultado

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

para comparar strings tem que usar strcmp

Se trata de um string estilo C

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  



  • Forum Statistics

    • Total Topics
      148561
    • Total Posts
      644243
×
×
  • Create New...