473,700 Members | 2,741 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 1216
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
1691
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
3575
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
2781
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
1983
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
1944
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
8546
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
1471
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
1413
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
2474
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
2208
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
8716
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
8641
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
9060
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...
1
6557
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5897
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();...
0
4397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4650
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2380
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2021
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.