1
0

」 feat: finished ex01

This commit is contained in:
2025-04-09 15:28:52 +02:00
parent a432c8defd
commit 02fe2e7791
3 changed files with 17 additions and 12 deletions

View File

@ -6,13 +6,13 @@
# By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/10/25 16:09:27 by adjoly #+# #+# #
# Updated: 2025/04/09 14:50:44 by adjoly ### ########.fr #
# Updated: 2025/04/09 15:28:36 by adjoly ### ########.fr #
# #
# **************************************************************************** #
SHELL = bash
NAME = whatever
NAME = iter
CC = c++

View File

@ -6,13 +6,13 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/09 14:56:23 by adjoly #+# #+# */
/* Updated: 2025/04/09 15:21:01 by adjoly ### ########.fr */
/* Updated: 2025/04/09 15:23:21 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
template<typename T> void iter(T *arr, int len, void(*func)(T &)) {
template<typename T> void iter(T *arr, int len, void(func)(T &)) {
for (int i = 0; i< len; i++) {
func(arr[i]);
}

View File

@ -6,21 +6,26 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/09 15:17:59 by adjoly #+# #+# */
/* Updated: 2025/04/09 15:20:20 by adjoly ### ########.fr */
/* Updated: 2025/04/09 15:25:40 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "iter.hpp"
#include <iostream>
void test(int &nb) {
void increment(int &nb) {
nb++;
}
int main(void) {
int test[4] = {1, 2, 3, 4};
void printInt(int &nb) {
std::cout << nb << std::endl;
}
for (int i = 0; i < 4; i++) {
std::cout << test[i] << std::endl;
}
int main(void) {
int arr[4] = {1, 2, 3, 4};
iter(arr, 4, printInt);
std::cout << "incrementing" << std::endl;
iter(arr, 4, increment);
iter(arr, 4, printInt);
}