Answer the question
In order to leave comments, you need to log in
How to print a string according to a given algorithm?
Hello, I am writing an interpreter again, and so ..... There is, for example, an input file containing instructions of the form:
A := B + C;;; ss D := E&G;;;;;
C := F <> z;;
X := \A;
read(D, base);
write(D, base);
<Operation1>
<Operation2>
#include <stdio.h>
#include <string.h>
#include "stringparse.h"
int operation_processing(FILE *file)
{
int i;
int j;
int k;
int size;
char buf[BUFSIZ];
char **parsed_string = NULL;
i = 0;
size = 0;
while(!feof(file))
{
fgets(buf, sizeof(buf), file);
strtok(buf, "\n");
parsed_string = string_parse(buf, &size);
for(i = 0; i < size; i++)
{
while(strcmp(parsed_string[i], ";"))
{
printf("%s ", parsed_string[i]);
i++;
if(!strcmp(parsed_string[i], ";"))
{
while(!strcmp(parsed_string[i], ";"))
{
printf("; ");
i++;
}
printf("\n");
}
}
}
}
return (0);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question