473,468 Members | 1,423 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I send a ppm to a function in another file

1 New Member
I have an assignment where I have to alter a ppm image and send it to a function in another file to print the new altered version. I'm really new to programming and I don't have much of a clue as to what to do. any help is appreciated!

Expand|Select|Wrap|Line Numbers
  1. #include "transform.h"
  2.  
  3.  
  4. int main (int argc, char *argv[])  {
  5.  
  6.     // declarations here
  7.     FILE *inFile;
  8.  
  9.  
  10.  
  11.     // open input file 
  12.     inFile = fopen("tiger.ppm", "r")
  13.     if (inFile == NULL){
  14.         fprintf(stderr,"Output failure. Exiting program\n");
  15.         exit(2);
  16.     }
  17.  
  18.  
  19.     // parseHeader function call here
  20.     parseHeader();
  21.  
  22.     // malloc space for the array (example given in assignment write-up)
  23.     struct pixel * image = (struct pixel *) malloc(sizeof(struct pixel) *         g_width * g_height);
  24.  
  25.  
  26.     // parseImage function call here
  27.     parseImage();
  28.  
  29.     // close input file 
  30.       fclose(inFile);
  31.  
  32.  
  33.     // manipulate the image according to command-line parameter
  34.     //        1: mirror image
  35.     //        2: upside down image
  36.     //        3: rotate to the right 90 degrees
  37.  
  38.     if(argv[1]){
  39.  
  40.         mirror();
  41.     }
  42.     if else(argv[2]){
  43.  
  44.         flipHorz();
  45.     }
  46.     if else (argv[3]){
  47.  
  48.         rotate();
  49.     }
  50.  
  51.  
  52.  
  53.     return 0;
  54. }
  55.  
  56.  
Expand|Select|Wrap|Line Numbers
  1. #include "transform.h"
  2.  
  3. int print(void){
  4.  
  5.     FILE *inFile
  6.  
  7.  
  8.     inFile = fopen("tiger.ppm", "r");
  9.     if(!inFile){
  10.         fprintf(stderr, "File open error. Exiting program\n");
  11.         exit(1);
  12.     }
}
Apr 7 '15 #1
1 1666
weaknessforcats
9,208 Recognized Expert Moderator Expert
There are no "other files".

When you build your program and you have multiple source files, each source file is independently compiled by the compiler creating an object file.

Then the linker copies each object file into the .exe and resolves all references between functions in the various files. This becomes your .exe.

When you execute all you have is one binary .exe file. All your functions are in that file. So to send data from one function to another all you do is call the function and pass the data (or its address)to the called function.
Apr 7 '15 #2

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

Similar topics

2
by: se7en | last post by:
okay, i cant seem to run a file with another file as an argument. e.g I want to send the file "x.met" as an argument when running the file "y.py" thanx -python newbie-
3
by: Peter | last post by:
Hello, Two newbie questions: 1) I have a javascript file with a function in it. From this function I want to access a variable in another javascript file -which is not inside a function. I...
5
by: rashmi | last post by:
how to use static function defined in one file in another file is that impposiible in 'c '
17
by: Eric_Dexter | last post by:
def simplecsdtoorc(filename): file = open(filename,"r") alllines = file.read_until("</CsInstruments>") pattern1 = re.compile("</") orcfilename = filename + "orc" for line in alllines: if not...
9
by: Sonnich | last post by:
Hi! I want to have a number of strings in another file, which I can include everywhere... but I cannot make them reachable from the top file. I have looked at var and global to to this but...
1
by: remya1000 | last post by:
how to send a .txt file to a printer. after creating a .txt file i need to send that .txt file to a printer.using vb.net and while sending that file to printer i need to tell, which printer i need...
17
by: sagar | last post by:
Hi, I have a C file(add.c) in which i have a function called add.now i want to call the same add function from another file sub.c .Can any1 tell how to do that... Thanks in advance Mark
1
by: mostafij | last post by:
// This code write random data into a file and every 5 seconds this //program send 5 seconds data into another file. #include <HEADER FILES> FILE *f1,*f2; int main(int argc, char *argv) {...
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
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...
1
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...
1
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...
0
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...
0
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 ...

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.