c - I need to write a program which reads from a file and updates it to the structure members -
I have given the file that should be read from. And as it encounters the Change your announcement and try this way In the * symbol, it should be updated with the next member of the structure. The input file is given below.
* 1234567890 * 2223334445 * Santoshkumar. . * 5/13, Bangalore, Karnataka * 0987654321 * 6665554447 * Nirmal * 13/5, Bangalore, Karnataka * Define Data Data # 5 [Four UserIDs [10]; Four cardid [10]; Four names [30]; Four addresses [100]; }; Int main () {struct data input [n]; File * FP; Fp = fopen ("input.txt", "r"); If (fp == NULL) {printf ("File Open Failed \ n"); Return -1; } (I = 0; i & lt; N; i ++) {fscanf ("% s *% s *% s *% s *% s", and input user [i], and input card [ i], & amp; input.name [i], & input.address [i]); } (I = 0; i & lt; N; i ++) {printf ("% s% s% s% s% s", input.userid [i], input.cardid [i], input Name [i], input.address [i]); } Fclose (fpose);
struct data { Four user-id [11]; 1/1 +1 for Nouel Care Cardid [11]; Four names [31]; Four addresses [101]; }; Structure data input [5]; // do not record below you used the input
fscanf (fp, "% s *% s *% s *% S *% s, and input [I]. Username, and input [i] cardid, and input [i] .name, and input [i] address);
fscanf the first argument is the file indicator for which you want to read.
Comments
Post a Comment