By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,919 Members | 1,625 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,919 IT Pros & Developers. It's quick & easy.

Converting strokes from C++ to C!

P: 2

I have problem,that I have to change programming language from C++ to C, but i don't get how to make these strokes work in C language!
There is the following strokes, what I need to change:

std::ifstream in("file.txt", std::ios::binary);
if (in.is_open()) {
int cnt=0;<char *>(&iSk), sizeof(int));
mas = (student*)calloc(iSk, sizeof(student));
while (cnt <= iSk) {<char *>(&mas[cnt]), sizeof(student));

I hope someone can help me,if there is some questions please write to me!
Sep 13 '10 #1
Share this Question
Share on Google+
3 Replies

Expert Mod 5K+
P: 8,916
Loop up the C standard library functions

Sep 13 '10 #2

P: 2
I tried and i get this one -

Expand|Select|Wrap|Line Numbers
  1. pf=fopen ("file.txt","r");
  2.    if (pf == NULL) {
  3.   perror("Mistake!");
  4.   return;
  5.   }
  6.   else {
  7.   int cnt=0;
  8.   cnt=getc(pf);
  9.   if(ch==EOF);
  10.   printf("File is empty!\n");
  11.   while (cnt !=EOF){
  12.   printf ("%c\n",cnt);
  13.   cnt=getc(pf);}
  14.   }
  15.  fclose (pf); 
Is it right?
Sep 14 '10 #3

Expert Mod 5K+
P: 8,916
You have your braces { } laid out strangely.
Line 9 looks wrong, looks like you are checking the wrong variable (ch not cnt) and you have a ; at the end of it.
Sep 14 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.