473,750 Members | 2,478 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

split a source into many files, where each file contains a function of the source

2 New Member
does anyone know a program split a c source into many c files, where each c file contains a function of the initial c source?

example:
this file:
Expand|Select|Wrap|Line Numbers
  1. //file myprog.c ------------------
  2. #include<stdio.h>
  3. int a(int a, int b){
  4.         return a+b;
  5. }
  6.  
  7. int b(int a, int b){
  8.         return a*b;
  9. }
  10.  
  11. int main(){
  12.         printf("a(10,10)=%d\n",a(10,10));
  13.         printf("b(10,10)=%d\n",b(10,10));
  14. }
  15. //end of file myprog.c------------------------
  16.  
turn into these files:
Expand|Select|Wrap|Line Numbers
  1. //file a.h--------------------------------------------
  2. int a(int a, int b);
  3. //end of file a.h---------------------------------------
  4.  
  5. // file a.c -------------------------------------------
  6. #include "a.h"
  7.  
  8. int a(int a, int b){
  9.         return a+b;
  10. }
  11. //end of file a.c--------------------------------------
  12.  
  13.  
  14. //file b.h-----------------------------------------
  15. int b(int a,int b);
  16. //end of file b.h---------------------------------
  17.  
  18. //file b.c-------------------------------------------
  19. #include "b.h"
  20.  
  21. int b(int a, int b){
  22.         return a*b;
  23. }
  24. //end of file b.c----------------------------------
  25.  
  26. //file main.c ------------------------------
  27. #include <stdio.h>
  28. #include "a.h"
  29. #include "b.h"
  30.  
  31. int main(){
  32.         printf("a(10,10)=%d\n",a(10,10));
  33.         printf("b(10,10)=%d\n",b(10,10));
  34. }
  35. //end of file myprog.c ------------------------------
  36.  

thanks for the help!
Oct 30 '15 #1
2 1222
weaknessforcats
9,208 Recognized Expert Moderator Expert
No, I don't.

Usually, code is written in many source files each with a header so there's not much call for a program like that.

Personally I would just build the files manually by cut/paste from the original file.
Oct 30 '15 #2
Nilton
2 New Member
oh, then I have a big problem.
I need to do this on some benchmarks, and one of these benchmarks has 288 ".c" files =/
Oct 30 '15 #3

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

Similar topics

1
1698
by: Krish | last post by:
I have requirement, that i get one big chunk of text file. This text file will have has information, that on finding "****End of Information****", i have to split them individual text file with our naming standard (unique id) and create them designated folder. This requirement should be created as a batch job and preferrably this job should monitor the folder where one big chunk of text file lands and process them immediately. ...
2
3578
by: Nicolas | last post by:
How to store multiple files in only one sql blod field in sql database Like I got a record for a house: ID Name addresss price attachments The field "attachments" may contains documents (pictures, word file for specification, autocad file for the plan etc.) We don't know in advance on many attachments will be uploaded. I should be able to Insert, Update,
3
2785
by: Stefan Schwarzer | last post by:
Hello, from time to time I want to inspect the source code of projects on remote computers.(*) I've googled for one or two hours but didn't find anything helpful. :-/ I'm looking for something like IDLE's path browser - i. e. a tree view and file view side-by-side - but with the following differences: - doesn't need an X connection to the remote computer where the sources are
1
1987
by: jonathan184 | last post by:
trying to rename filenames and extensions then add a header in line1 of each file if the header existed in line 1 to go to the next file. but i am getting error explciti errors Here is my code I am using #!/usr/bin/perl user warnings;
4
1949
by: lyealain | last post by:
how to store many files in one database fields?? i manage to store one file into database field.. but fail to store many files..... how should i do that>> one database field for many files name.. is this way correct??? or each field for one filename?? 10 fields for 10 files??
6
8547
by: Bob Bedford | last post by:
Hi all, I've an XML file that takes more than the hosting time limit to be readed by a PHP script. What I'd like to do is split the large XML file (can be more than 30MB) in little parts and keep the header for every file. Here is the idea:
3
1473
by: developing | last post by:
Hello people, I downloaded a few open source frameworks in hopes of looking at the source and learning a few things. All was fine till I got totally lost on where to start. i downloaded the source for *nix... eg: I downloaded the source for php framework. Now I want to see how 'echo' function is implemented...I can't figure out where to look. Same thing with an app called 'wireshark'...i downloaded the source for mac os x, but i cant...
3
1415
by: K. | last post by:
Hello! Is it possible to create i.e. truck.gz compressed file, which contains i.e. 4 files: truck1.jpg, truck2.jpg, truck3.jpg, truck4.jpg? If so, how should I implement such code to achieve this using gzwrite and any other functions? I couldn`t find the example on internet.
4
2476
by: maxjessop | last post by:
Hi, I have a .txt file with blocks of text separated by blank lines. I need to save each block into separate .txt files on the server. I am a complete novice and so far only managed to load the .txt and echo it back. I've spent two days searching for examples but have come up blank, I think explode() into an array and then write the arrays to txt files is the way to go. Any help would be appreciated thanks.
8
2210
by: thistle | last post by:
I have this code to merge files. the files language is persian. it merges them but I want each file to be written in a new line. for example if I have 9 files, the output should be 9 lines. each line is one file. the problem is that I don't know where to put replace('\n', " ") to omit newlines of a file and where to add '\n' to go to the next file. import os,shutil path = 'فناوري' f=open("wwww.txt","a", encoding = 'utf-8') for r,d,fi in...
0
9001
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8839
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9397
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9257
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8264
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6081
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3327
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 we have to send another system
2
2807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2226
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.