scan from a txt file to an array the following- in C. (pleasenote the commas and dots do not need to be scanned into the array,only spaces and numbers, and order matters)
Y,R,Y,R,Y,R.
R,Y, , ,Y,R.
R,Y,R, , ,R.
Answer
solution:
code:
#include <stdio.h> #include <stdlib.h> int main() {// file pointer to read the data from file FILE *filePointer; //array to strore the read data from file. // considering file is nothaving more than 100 characters. char filedata[100], c; int counter= 0,i; // Opening the file filePointer = fopen(“File1”, “r”); // iffile pointer is null that means file cannot be opened if(filePointer == NULL) {
OR
OR