I have the following C # code snippet
string[] lines = File.ReadAllLines(@"C:\test.txt"); for(int i=0; i<lines.Length; i++) Console.WriteLine(lines[i]);
Can you help me convert it to C.
Thanks!
If you plan to use Ansi Standard C, you will need fopento fgetsand printfto do what you want.
fopen
fgets
printf
Here is a tutorial that does practically what you want .
Take a look at fopen and fgets .
fgets , , .
, :
, (ReadAllLines ) , - , , UTF16, stdout...
, , , , - ( / / ).
, . , , , fread/fwrite (, 4 ) .
++.
ifstream input("test.in"); string line; while(getline(input, line)) { //Your code for the current line }
fgets :
, fgets.