i want to write a program that reads and convert instructions into some numbers like for example
expected output is
where first 4 digits means instruction number
next 4 is the first number
last 4 is the 2nd number
what function can i use to read the input
Make a list of the instructions you want to support and their values.
You read in the instruction and break it up into the three parts:
the instruction, the first number, and the second number.
Then you can use something akin to
printf("%04d%04d%04d", value_of_instruction, first_number, second_number);
yes i know that
but how do i break it up?
should i use sscanf?
Thats one possiblity. You also have two delimiters (the space and the comma) so you could also use strtok()