473,386 Members | 1,748 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,386 software developers and data experts.

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

2
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 1209
weaknessforcats
9,208 Expert Mod 8TB
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
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
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...
2
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...
3
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...
1
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...
4
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.....
6
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...
3
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...
3
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...
4
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...
8
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.