Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * main.c
- *
- * Ce fichier contient la fonction main() du programme de manipulation
- * de fichiers pnm.
- *
- * @author: Nom Prenom Matricule
- * @date:
- * @projet: INFO0030 Projet 1
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <assert.h>
- #include <unistd.h>
- #include <ctype.h>
- #include <getopt.h>
- #include "pnm.h"
- struct RGB_t
- {
- unsigned short red;
- }
- struct PBM_t
- {
- unsigned rowsSize;
- unsigned columnsSize;
- unsigned **matrix;
- };
- PBM *create_pbm(unsigned rowsSize, unsigned columnsSize)
- {
- unsigned **matrix = malloc(columnsSize * sizeof(unsigned *));
- if (matrix == NULL)
- return NULL;
- for (unsigned i = 0; i < columnsSize; i++)
- {
- matrix[i] = calloc(rowsSize, sizeof(unsigned));
- if (matrix[i] == NULL)
- {
- for (unsigned j = i; j >= 0; j++)
- free(matrix[i]);
- free(matrix);
- }
- }
- ¨
- PBM *pbm = malloc(sizeof(PBM));
- if (pbm == NULL)
- {
- for (unsigned i = 0; i < columnsSize; i++)
- free(matrix[i]);
- free(matrix);
- }
- pbm->rowsSize = rowsSize;
- pbm->columnsSize = columnsSize;
- pbm->matrix = matrix;
- return pbm;
- }
- if (buffer[0] != '#')
- {
- }
- int main(int argc, char *argv[]) {
- char *optstring = "";
- /* Insérez le code ici */
- return 0;
- }
- typedef struct PNM_t PNM;
- struct PNM_t
- {
- PBM *pbmxd;
- Type format;
- unsigned colonnes;
- unsigned lignes;
- char filename[50];
- };
- struct PBM
- {
- unsigned colonnes;
- unsigned lignes;
- char filename[50]; /LOIC
- };
- PNM *createPNM(unsigned colonnes, unsigned lignes)
- {
- PBM *pbm = malloc());
- PNM *pnm = malloc(sizeof(PNM));
- if (pnm == NULL)
- {
- free(pnm2);
- }
- pnm->pbmxd = pbm;
- printf("FILENAME %s\n", pnm->pbmxd->);
- }
- void get_pnm_filename(PNM *pnm)
- {
- return pnm->filename;
- };
- int main(*argv[])
- {
- char *filename = "FRANCOIS";
- PNM *pnm = createPNM(5, 25);
- PNM **pnm = malloc(25 * sizeof(pnm));
- PNM ***pnms = malloc(25 * sizeof(pnms *));
- for (unsigned i = 0; i < 25; i++)
- {
- pnms[i] = malloc(25 * sizeof(pnm));
- if (pnms[i] != NULL)
- {
- for (unsigned j = i; j >= 0; j--)
- {
- free(pnms[j]);
- }
- free(pnms);
- }
- }
- pnms[2][3]
- set_pnm_filename(pnm, FRANCOIS);
- }
- void set_pnm_filename(PNM *pnm, char *value)
- {
- strcpy(pnm->filename, value);
- };
- void strcpy(char *dest, char *src)
- {
- for (unsigned i = 0; a[i] != '\0'; i++)
- a[i] = b[i];
- a[i] = '\0';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement