473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

compilation problems in C

8
Hi!
I write a small function in C, but there are some errors in it..please help me in solving these errors so that i can compile the program correctly..


Expand|Select|Wrap|Line Numbers
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. // Definition of a player
  5. typedef struct PLAYER
  6. {
  7.     int id;
  8.     char player_name[ 50 ];
  9.     double ability;
  10.     double potential;
  11. }
  12.  
  13. // Function:   main()
  14. // Purpose:    Main function for the program
  15.  read()
  16. {
  17.     FILE *p_file;        // File being read in from
  18.     PLAYER *player;        // Player stored in file
  19.  
  20.     // Open the file to read from
  21.     p_file = fopen( "file.txt", "r" );
  22.  
  23.     // Read out the player information
  24.     fread( &player, sizeof( PLAYER ), 1, p_file );
  25.  
  26.     // Print the players name to the screen
  27.     printf( "%s\n", PLAYER.player_name );
  28.  
  29. } // main()

With Regards,

Areeba
Apr 9 '07 #1
2 1149
JosAH
11,448 Expert 8TB
Hi!
I write a small function in C, but there are some errors in it..please help me in solving these errors so that i can compile the program correctly..
Expand|Select|Wrap|Line Numbers
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3.  
  4. // Definition of a player
  5. typedef struct PLAYER
  6. {
  7.     int id;
  8.     char player_name[ 50 ];
  9.     double ability;
  10.     double potential;
  11. }
  12.  
  13. // Function:   main()
  14. // Purpose:    Main function for the program
  15.  read()
  16. {
  17.     FILE *p_file;        // File being read in from
  18.     PLAYER *player;        // Player stored in file
  19.  
  20.     // Open the file to read from
  21.     p_file = fopen( "file.txt", "r" );
  22.  
  23.     // Read out the player information
  24.     fread( &player, sizeof( PLAYER ), 1, p_file );
  25.  
  26.     // Print the players name to the screen
  27.     printf( "%s\n", PLAYER.player_name );
  28.  
  29. } // main()
  30.  
With Regards,

Areeba
There is no main() function defined at all.

kind regards,

Jos
Apr 9 '07 #2
RedSon
5,000 Expert 4TB
Using a good, clear thread title is important. The reasons for this are:

* We want this site to grow, many of our new members find the site using a search engine, by using a good thread title you will help us grow the site by helping us get better search engine rankings.
* Using a good title will benefit you too because other members of the forum will be less likely to skip over your thread and it allows the experts to quickly scan through the forum for questions they know the answer to.
* If the threads are well titled it allows other users to easily see if there have been any threads that could be relevant to their own current problem.
* It is in everybody's best interests to post properly titled threads as the more time the moderators have to spend on managing titles the less time they have available to give answers to the questions posed.
Apr 9 '07 #3

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

Similar topics

2
by: Ram Sundaram | last post by:
Hi, I am trying to port some linux code to windows under Visual studio. The regex package currently used is the GNU regex package which calls for <strings.h>. This is not found in visual studio....
12
by: wanghz | last post by:
Hi, Could I ask some questions about the conditional compilaion? Suppose I have three simple files: a.c, b.c and c.h /* --------a.c--------- */ #include <stdio.h> #include "c.h" int...
2
by: Tommy Vercetti | last post by:
In Visual Studio .NET 2003, I do the following 1) File->New->Project 2) Visual C++ Projects->.NET->Windows Forms Application 3) Project->Add New Item->C++ File 4) Clear the new C++ file and...
3
by: Dan | last post by:
Hi, I have a problem using an aspx page with a Control on it. I get the following error message Compiler Error Message: CS1595: 'Test.Class2' is defined in multiple places; using definition...
2
by: Kevin R. | last post by:
I have been ignoring this problem for a few weeks now, but it's becoming a bit annoying not to mention unproductive. Here it goes: I compile my project with no errors. Then after I debug/run it,...
2
by: Steve | last post by:
Hi I'm receiving the following error whenever a new build is placed onto our production server: Timed out waiting for a program to execute. The command being executed was...
6
by: alban | last post by:
Hello I have got some problems of compilation on a AIX IBM, I use the XLC compilator (And I can't install another one). I try to compile code Pro*c ".pc" (oracle), I need do a pre-compilation...
35
by: mwelsh1118 | last post by:
Why doesn't C# allow incremental compilation like Java? Specifically, in Java I can compile single .java files in isolation. The resulting individual .class files can be grouped into .jar files....
1
by: BSand0764 | last post by:
I'm getting an error that I can't seem to resolve. When I compile the Functor related logic in a test program, the files compile and execute properly (see Listing #1). However, when I...
1
by: Roumen Petrov | last post by:
Hi list members, It seems to me that this is discussed many times in the past but without progress. As I understand in general there is no objections and preferred cross-compilation has to be...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.