hello,
i have tried alot of things about this but in the end i did it using flat file.
but the response is so slow -_-"
i'm passing a character between C and C# using a text file.
this operation is continuous .I mean C put char in the text then C# read the
character erase from the file and so on .....
the C check if the file is in use by checking if it's empty ...if so it writes the value
otherwise it return "busy" notification.
but this operation is so slow.
this is the code :
C#
C
i have tried alot of things about this but in the end i did it using flat file.
but the response is so slow -_-"
i'm passing a character between C and C# using a text file.
this operation is continuous .I mean C put char in the text then C# read the
character erase from the file and so on .....
the C check if the file is in use by checking if it's empty ...if so it writes the value
otherwise it return "busy" notification.
but this operation is so slow.
this is the code :
C#
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.ComponentModel;
using System.Data;
namespace TestCommand
{
class Program
{
static void Main(string[] args)
{
Boolean a = true;
while (a)
{
checkFile:
try
{
TextReader tr = new StreamReader("test.txt");
String x = tr.ReadLine();
tr.Close();
TextWriter tw = new StreamWriter("test.txt");
tw.WriteLine("");
tw.Close();
switch (x)
{
case "L":
Console.Write("LEFT");
break;
case "R":
Console.Write("Right");
break;
case "F":
Console.Write("Forward");
break;
case "B":
Console.Write("Backward");
break;
}
}
catch (IOException)
{
goto checkFile;
}
}
}
}
}
C
Code:
#!C:\Ch\bin\ch.exe
#include <conio.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
int main(void)
{
FILE *test1 ;
char x;
char data;
test1=fopen("test.txt","r");
while (!feof(test1)) {
fscanf(test1,"%c",&x);
}
if(x == 0)
{
test1=fopen("test.txt","w");
data='Y';
fprintf(test1,"%c",data);
fclose(test1);
printf("The entered value is %c",data);
}
else
{
printf("Controlling is busy");
fclose(test1);
}
return 0;
}
Comment