473,503 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Converting strokes from C++ to C!

2 New Member
Hi,

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;

in.read(reinterpret_cast<char *>(&iSk), sizeof(int));
mas = (student*)calloc(iSk, sizeof(student));
while (cnt <= iSk) {
in.read(reinterpret_cast<char *>(&mas[cnt]), sizeof(student));
cnt++;
}
}
in.close();

I hope someone can help me,if there is some questions please write to me!
Sep 13 '10 #1
3 1205
Banfa
9,065 Recognized Expert Moderator Expert
Loop up the C standard library functions

fopen
fread
fwrite
fclose
Sep 13 '10 #2
kiksu
2 New Member
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
Banfa
9,065 Recognized Expert Moderator Expert
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

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

Similar topics

8
5714
by: prabha | last post by:
Hello Everybody, I have to conert the word doc to multiple html files,according to the templates in the word doc. I had converted the word to xml.Also through Exsl ,had finished the multiple...
5
2493
by: Robert | last post by:
I have a series of web applications (configured as separate applications) on a server. There is a main application at the root and then several virtual directories that are independant...
6
4911
by: Al Bahr | last post by:
H I need to combine Ink strokes with the background image into a bit map. Would appreciate any help Thank A
3
2398
by: Mary | last post by:
Hi, Does anyone know of any software out there that would convert an application written in VBScript to either VB.NET or C#/C++ quite quickly for me, or will I have to re-write the application...
3
5639
by: Paulers | last post by:
Hello, I need to emulate keyboard strokes from a console application. The console application monitors a textfile and when something is matched in a text file I need the matched string outputted...
1
1393
by: sreenulanka | last post by:
I have five panel each one layout is set to gridbag layout.and also i have one main panel, layout is box layout.all components add to container.my page is larger than screen.it is not moving with...
11
4452
cheezylu
by: cheezylu | last post by:
I'm working on a site where my client will be able to maintain some of the text on the site using input boxes and such driven by PHP and MySQL. The problem I am running into is making it easy for...
0
1345
by: abcd | last post by:
Is there a way to capture key strokes on a system using python (other than pyHook)? can wxPython capture keystrokes for the system (not just, say a text box)? thanks
4
3716
by: =?Utf-8?B?QWxleGFuZGVy?= | last post by:
Hi! I am new to C#. I read two C# books in the last two days which only covered the basics. And now I am on my third day. The books were really bad, because they did not cover windows applications,...
11
10544
by: shadyabhi | last post by:
How can i accept key strokes like Ctrl+A etc etc ... i mean combination of 2 keys... Pls give a small peice of code to demonstrate... i use gcc under linux platform
0
7199
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7273
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7451
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4667
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3150
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1501
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.