473,407 Members | 2,629 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,407 software developers and data experts.

Does anyone knows how to read a data from the other file?

I can't link to the other file called A1.c, A2.c and A3.c respectively. Does anyone knows how to link to the other .c file from the following .c file?
Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5.     int choice;
  6.  printf("             Main Menu\n");
  7.  printf("             =========\n\n");
  8.  printf("1.Simple Editor with Speed Calculation\n");
  9.  printf("2.Simple Spell Checking\n");
  10.  printf("3.Find & Replace\n");
  11.  printf("4.Quit\n\n");
  12.  
  13.          do
  14.         { 
  15.          printf("Please enter your choice: ");
  16.          scanf("%d",&choice); 
  17.         }
  18.         while(choice<1 || choice>4); 
  19.  
  20.          if(choice==1)
  21.         {
  22.          fopen("A1.c","r"); 
  23.         }  
  24.         else if(choice==2)
  25.         {
  26.          fopen("A2.c","r");
  27.          }
  28.         else if(choice==3)  
  29.         {
  30.          fopen("A3.c","r");
  31.          }
  32.         else if(choice==4)
  33.         {
  34.          printf("Welcome to come next time.");
  35.          exit(1);
  36.         }
  37.  
  38.  system("PAUSE");
  39.  return 0;   
  40. }
Nov 27 '09 #1
12 1604
newb16
687 512MB
If you are trying to execute the C/C++ code written in Ax.c file based on user's choice, it's not done that way. You need to compile them and link resulting object files according to your compiler's documentation.
Nov 27 '09 #2
But my one just use C, not Visual C/C++...What's the comand of it? I am a new guy for using C language...So I don't know what the command code is for this case.
Nov 27 '09 #3
weaknessforcats
9,208 Expert Mod 8TB
You need a makefile or you can identify these other files on the OS command line.

The format of that line shouloe be in yhour compiler documentation.

Are you using Visual C++?

If so, just add these files to your project along with tile file containing main and click on build.
Nov 27 '09 #4
I am sorry, I use C not visual C, C++
Nov 28 '09 #5
weaknessforcats
9,208 Expert Mod 8TB
What compiler are you using then?
Nov 28 '09 #6
Actually, I am only using Notepad...Then how can I link them?
Dec 3 '09 #7
Can anyone give me an example?
Dec 3 '09 #8
newb16
687 512MB
You can't run C or (C++ if that matters) program without compiler. ( i.e. make and run executable having source code). Use of notepad hints that you use windows - get mingw compiler if you have no compiler yet or tell us what compiler do you have.
Dec 3 '09 #9
I have DEV C++... but I seldom use it...Could you give me an example to link the .c files to .h file?
Dec 3 '09 #10
newb16
687 512MB
If dev c++ uses gcc as a compiler, you may try
g++.exe main.cpp a1.cpp a2.cpp a3.cpp
It willl compile them and link obj files.
Dec 3 '09 #11
But I should open us C project...not C++...what should I include in the .h file to link the other C files within the same project?
Dec 3 '09 #12
weaknessforcats
9,208 Expert Mod 8TB
You are asking fundamental questions whose answers are in any book on C or C++. I recommend the C++ Primer Plus 5th Edition by Stephen Prata.

There's also Google and Wikipedia.

We are available to assist getting your through specific problems but we are not set up to act as tutors.
Dec 3 '09 #13

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

Similar topics

1
by: lawrence | last post by:
I'm trying to read up on the rfc's that govern form inputs. Much of what I'm reading is stuff I didn't know before and some of it is alarming. This one left with me questions: ...
11
by: BoonHead, The Lost Philosopher | last post by:
I think the .NET framework is great! It's nice, clean and logical; in contradiction to the old Microsoft. It only saddens me that the new Microsoft still doesn't under stand there own...
0
by: Uma Vivek | last post by:
Hi, I have a problem with Flash remoting via .NET . I seem to have all the code right, but flash does not seem to display the data at all. Here's is what Ive done so far... (1) Ive...
38
by: Martin Marcher | last post by:
Hi, I've read several questions and often the answer was 'C knows nothing about .' So if C knows that little as some people say, what are the benefits, I mean do other languages know more...
4
by: Chris Tanger | last post by:
Context: C# System.Net.Sockets Socket created with constructor prarmeters Internetwork, Stream and TCP everything else is left at the default parameters and options except linger may be changed...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
5
by: mkaushik | last post by:
Hi everyone, Im just starting out with C++, and am curious to know how "delete <pointer>", knows about the number of memory locations to free. I read somewhere that delete frees up space...
6
by: dr | last post by:
does anyone see what is wrong with my .gif download logic? no matter what image url i try it downloads a junk file that can't be opened in any paint program. System.Net.WebRequest myRequest =...
1
by: aberry | last post by:
I have text file which contain Unicode data (say inp.txt) I read file using following code:- import codecs infile = codecs.open('C:\\tdata\\inp.txt','r','utf-16',errors='ignore') data =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.