Hi friends I need urgent help. now three variables we printed to a file received from the user. This variable to another file, the user wants to take that file and the value of the variable is a variable, you need to do. And this event is the first change the variables in the file must be changed. How can we do?

Recommended Answers

All 5 Replies

1. The instructions are unclear

2. try to post your code

> now three variables we printed to a file received from the user. This variable to another file, the user wants to take that file and the value of the variable is a variable, you need to do. And this event is the first change the variables in the file must be changed. How can we do?

This is probably the worst grammar I have read in a long time. But in an effort to help beyond the barriers of the spoken language, I will attempt to repair your grammar and restate your question. I will use square brackets to indicate words added and parenthesis to indicate words replaced:

> Now, [there are] three variables [that] (my program) print(s) to a file from user [input]. (These) variable (in that file must be copied to) another file, (but here is what) (I) need to do: First, (I must) change the variables in the (first) file (before copying it to the second file). How can (I) do (this)?

Well engineer61, I'm not sure what this has to do with a linklist as your subject described, but why can't you just write to the two files from the user input instead of writing to one of them and then reopening that one to modify it to create a second one? It almost sounds like you need to make two separate programs. Can you elaborate?

Here is engineer61's message to me regarding the details of the problem

I already asked him to post the code here but we might be having communication issues since most of the text is in turkish(by google translator)

Try to bear with it and maybe you can help him... cause I can't

firstly thank you for your interest.

Let me tell like this better:
a logic circuit connected to a file that lists gerçeklenmesi.Önce devre.txt olusturduk.Bu a given circuit, the entries in the file, such as types of doors and use the list of events will take place depending on the actual values ​​tutuldu.Sonra komut.txt writing to a file so that file should be What we say:

Logic circuit simulator should work from the console. The user program runs the program first
"Devre.txt" within the lines must be interpreted and run commands.
2. The console prompt (the warning) character '>' must see. In other words, the user is ready to take command
shows that.
3. When one of the following commands, depending on the user that the command is executed after the new process
for the command prompt (warning) character '>' must see on the console. (C-output-to command is entered.)
4. The commands does not matter whether large caps or small caps. (Not case sensitive)


commands:
> H <giriş/çıkış biri/birileri> on the tip end / ends logic-1 does
> L <input / output end of the one / someone> on the end / ends logic-0 makes
> G <input / output end of the one / someone> on All input / outputs to illustrate:
> S * kullanılır.İlgili end / ends the level (0.1) shows the console
> I initialize the circuit to
> Q for the circuit simulation
> Y <devre.txt> "devre.txt" Load the circuit file
> K <komut.txt> "komut.txt" file commands executed in the meat
> Check out the C simulator

as part of my code:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<conio.h>

void bir_yap(void);
void sifir_yap(void);
void seviye_goster(void);
void tum_seviye_goster(void);
void ilklendir(void); 
void simule_et(void); 
void d_yukle(void);
void k_icraet(void);
 typedef struct{
  int *deger;
  char kapi;
  char konum;
}giris;

giris a,b,c,d,e,f;

FILE *fp;
FILE *kp;
int main()
{
char sec;  
  fp = fopen("devre.txt", "w");
  /*fprintf(fp,".giris\t a\t b\t c\t\n");
  fprintf(fp,".cikis\t f\t\n");
  fprintf(fp,".kapi\t nor\t 2\t d\t a\t b\t c\t 1\t\n");
  fprintf(fp,".kapi\t nand\t 2\t e\t b\t c\t 1\t\n");
  fprintf(fp,".kapi\t exor\t 2\t f\t d\t e\t 1\t\n ");
  fprintf(fp,".son");*/
 
  printf("girislistesi icin a degiskeni giriniz:");
  scanf("%d",&a.deger);
  printf("a girisin bagli oldugu kapi  giriniz:");
  scanf("%s",&a.kapi);
  printf("a girisin ara giris(E) mi ana girismi(H) oldugunu   giriniz:");
  scanf("%s",&a.konum);
  
  printf("girislistesi icin b degiskeni:giriniz");
  scanf("%d",&b.deger);
  printf("b girisin bagli oldugu kapi  giriniz:");
  scanf("%s",&b.kapi);
  printf("b girisin ara giris(E) mi ana girismi(H) oldugunu  giriniz:");
  scanf("%s",&b.konum);
  
  printf("girislistesi icin c  degiskeni giriniz:");
  scanf("%d",&c.deger);
  printf("c girisin bagli oldugu kapi  giriniz:");
  scanf("%s",&c.kapi);
  printf("c girisin ara giris(E) mi ana girismi[H)  giriniz:");
  scanf("%s",&c.konum);
  
  printf("cikislistesi icin d degiskeni ");
  if(((a.deger)||(b.deger))==1){ 
   printf("0\n",d.deger);}
  else 
  if(((a.deger )&& (b.deger))==0){
  printf("1\n",d.deger);}
 printf("d nin  bagli oldugu kapi  giriniz:");
  scanf("%s",&d.kapi);
  printf("d nin  ara giris(E) mi ana girismi(H)  giriniz:");
  scanf("%s",&d.konum);
  
  printf("cikislistesi icin e degiskeni ");
  if(((b.deger)||(c.deger))==0){
  printf("1\n",e.deger);}
  else 
  if(((b.deger)&&(c.deger))==1){
  printf("0\n",e.deger);}
  printf("e nin bagli oldugu kapi  giriniz:");
  scanf("%s",&e.kapi);
  printf("e nin  ara giris(E) mi ana girismi[H)  giriniz:");
  scanf("%s",&e.konum);
  
  printf("cikislistesi icin f degiskeni ");
  if((a.deger)!=(b.deger)){
  printf("1\n",f);}
  else if((a.deger)==(b.deger)) {
  printf("0\n",f);}
  printf("f_cikisin bagli oldugu kapi  giriniz:");
  scanf("%s",&f.kapi);
  printf("f cikisin  ara giris(E) mi ana girismi[H)  giriniz:");
  scanf("%s",&f.konum);
  
  fprintf(fp,".giris\t %d\t%d\t%d\t\n",a.deger,b.deger,c.deger);
  fprintf(fp,".cikis\t %d\t\n",f.deger);
  fprintf(fp,".kapi\t nor\t2\t%d\t%d\t%d\t3\n",d.deger,a.deger,b.deger);
  fprintf(fp,".kapi\t nand\t2\t%d\t%d\t%d\t1\n",e.deger,b.deger,c.deger);
  
  fprintf(fp,".kapi\t exor\t2\t%d\t%d\t%d\t1\n",f.deger,d.deger,e.deger);
  kp=fopen("komut.txt","w");
  fscanf(fp,"%d\t%d\t%d",a.deger,b.deger,c.deger);
  printf("%d\t%d\t%d",a.deger,b.deger,c.deger);
  
 
 do {
      printf("\n LOJIK DEVRE SİMİLASYONUNA HOSGELDINIZ!\n");
      printf("************************************\n");
      printf("\n[1] - >H < giris/cikisi 1 yapmak>");
      printf("\n[2] - >L < giris/cikisi sifir yapmak >");
      printf("\n[3] - >G <giris/cikis seviyelerini göstermek>");
      printf("\n[4] - >G*< tüm giris/cikis seviyelerini göstermek için:>");
      printf("\n[5] - >I < devreyi ilklendirmek >");
      printf("\n[6] - >S < devreyi simüle etmek >");
      printf("\n[7] - >Y <devre.txt dosyasından devreyi geri yuklemek>");
      printf("\n[8] - >K <komut.txt icin komutlari gerceklestirmek>");
      printf("\n[9] - >C <cikis>");
      
      printf("\n\n\n SECIMINIZ = ");
      sec = getch();
     /* switch (ca) {
         case '1':bir_yap(); break;
         case '2':sifir_yap() ; break;
         case '3':seviye_goster(); break;
         case '4':tum_seviye_goster(); break;
         case '5':ilklendir(); break;
         case '6':simule_et(); break;
         case '7':d_yukle() ; break;
         case '8':k_icraet();
      
         }*/
  } while(sec !='9'); 
  
  
  
  
  
  
  
 
 fclose(fp);
 fclose(kp);
 
getch();}

Well, a logic circuit simulator is not a terribly difficult project. I would approach it by creating a generic gate structure containing two gate structure pointers as inputs (assuming thats how many inputs you need), an enum with all the supported gates to define that structure, a function that accepts that structure's pointer as a parameter which simulates its function and returns the output of the gate logic as an integer... Something like this

// Types of gates supported
typedef enum {
    AND_GATE,
    OR_DATE,
    NAND_GATE,
    NOR_GATE,
    POWER
} GateType;

// Define a named typedef for our linked list structure
typedef struct GateObject GateObject;

// Define a gate object type
struct GateObject {
    GateObject *Input_A;
    GateObject *Input_B;
    GateType Type;
};

// A recursive function that simulates the behavior of a single gate
int ProcessGate(GateObject *in_Gate) {
    if (in_Gate == NULL)
        return 0;
    switch (in_Gate->Type) {
        case AND_GATE: return ProcessGate(in_Gate->Input_A) & ProcessGate(in_Gate->Input_B);
        case OR_GATE: return ProcessGate(in_Gate->Input_A) | ProcessGate(in_Gate->Input_B);
        case NAND_GATE: return !(ProcessGate(in_Gate->Input_A) & ProcessGate(in_Gate->Input_B));
        case NOR_GATE: return !(ProcessGate(in_Gate->Input_A) | ProcessGate(in_Gate->Input_B));
        case POWER: return 1;
    }
    return 0;
}

You probably need to only test the last gate attached to the output line for an accurate answer. This is just a rough estimate of what you need. Build upon it and see where it takes you. You are more than welcome to post what you have so-far and get more help along the way.

He thanked you for helping him out.. I think he got it now

Also Engineer61 is requesting to delete the post containing his codes could I do this or maybe request an admin to do it?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.