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

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

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 1658
weaknessforcats
9,208 Expert Mod 8TB
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) {...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.