language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
// // main.c // merge_bmp_images // // Created by 김주형 on 2021/09/28. // #include <stdio.h> #include <stdlib.h> #include "windows.h" #define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4) // 각 행은 반드시 4bytes의 배수이다. typedef unsigned char BYTE; int main() { FILE *file, *file1, *file2, *file3, *file4; // 파일 포인터 BI...
C
#include <stdio.h> #include "apto.h" // (2.12.2) float area_Apto(tApto *x) { return x->AreaC; } // (2.12.1) float price_Apto(tApto *x) { if (x->Lazer == 'S') return x->pM2AC * x->AreaC * (0.9 + (float) (x->Andar / x->nAndares))*1.15; else return x->pM2AC * x->AreaC * (0.9 + (x->Andar / (floa...
C
/* +----------------------------------------------------+ | | | ####### | | # # #### # # ###### ##### | | # # # # # # # # | | # # # #### ##### ...
C
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <semaphore.h> #include <pthread.h> int* prepare_return_value_int(int value) { int *result_value_ptr; result_value_ptr = malloc(sizeof(int)); if (result_value_ptr == NULL) { perror("malloc"); exit(EXIT_F...
C
/** * @file db_test.c * Tests for DB hash * * @remark Copyright 2002 OProfile authors * @remark Read the file COPYING * * @author Philippe Elie */ #include <sys/types.h> #include <sys/time.h> #include <sys/resource.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <fcntl.h> #include "op_s...
C
/* Par o impar? */ #include<stdio.h> int main() { int input; printf("Par o impar?\n\nIngrese un numero: "); scanf("%d", &input); printf("El numero es %s.\n\n", (input & 1 ? "impar" : "par")); system("PAUSE"); return 0; } /* 1000 0100 0010 0001 1011 8*1 + 4*0 + 2*1 + 1*1 = 11 1101 1001 0001 1110...
C
#ifdef __clang__ int maxB_int(int a, int b) { return a < b ? b : a; } int minA_int(int a, int b) { return a < b ? a : b; } int minB_int(int a, int b) { return a > b ? b : a; } int maxA_int(int a, int b) { return a > b ? a : b; } unsigned int maxB_unsigned_int(unsigned int a, unsigned int b) { return...
C
#include <stdio.h> #include <stdlib.h> /* Numbers (positive integers expressed in base ten) that are (evenly) divisible by the number formed by the first and last digit are known as gapful numbers. Example 187 is a gapful number because it is evenly divisible by the number 17 which is formed by the first and last...
C
#include "gps.h" uint8_t UPDATE_10HZ[] = PMTK_SET_NMEA_UPDATE_10HZ; uint8_t UPDATE_ONLY_RMC[] = PMTK_SET_NMEA_OUTPUT_RMCONLY; uint8_t UPDATE_POSITION_10HZ[] = PMTK_API_SET_FIX_CTL_5HZ; float currentKnots = 0; bool InitializeGPS(void) { //Pins and interrupts are initialized in BOARD_InitPeripherals(void) ...
C
#include <stdio.h> #include <stdlib.h> #include <signal.h> #include <sys/types.h> #include <unistd.h> #include <pwd.h> #include <string.h> static void my_alarm(int signo) { struct passwd *rootptr; printf("in signal handler\n"); if((rootptr=getpwnam("root"))==NULL) printf("getpwnam(root) error\n...
C
/* The main jaunty engine, responsible for keeping track of * levels, actors, etc... */ #include "jaunty.h" #include <stdio.h> /* Utility functions */ /* returns a number that is a number, 'a', converted into the nearest number * that is a whole power of 2 (rounding up) */ #define mkp2(a) (int)powf(2.0, ceilf(l...
C
#define NULL (0) typedef struct _Node { int data; struct _Node *next; } Node; void *malloc(int); Node *new_node(int data) { Node *p; p = malloc(sizeof(Node)); p->data = data; p->next = NULL; return p; } void print_list(Node *p) { printf(" %d ", p->data); if (p->next == NULL) printf("\n"); el...
C
#include <stdio.h> int process(int (*pf)(int, int)) { printf("process host\n"); int a = 1, b = 2, c = 3; c = (*pf)(a, b); printf("returned value of c = %d\n", c); return(c); } int funct1(int a, int b) { int c = 0; printf("guest function funct1\n value of c = %d\n", c); printf("Value of a = %d\n Value...
C
#include <stdlib.h> typedef struct IntList{ int val; struct IntList * next; int refcount; }IntList; IntList * allocateIntList(IntList * p){ static IntList * pool=NULL; if (!p){ if (!pool){ IntList * p=(IntList*)malloc(sizeof(IntList)*1000); for (int i=0;i<1000;i++){ p[i].next=pool; pool=p+i; } ...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <assert.h> int global_var = 1; void* global_reciprocal (void* arg) { if (global_var != 0) { // bide our time for (int i = 0; i < 100; ++i) { int j = i * i; } // then return our reciprocal global_var = 1/global_va...
C
#include <stdio.h> #include <stdlib.h> #include "lists.h" #include <string.h> /** * get_nodeint_at_index - returns the nth node of a listint_t list. *@head: pointer to start of list. *@index: index of the node starting at 0. * Return: nth node. */ listint_t *get_nodeint_at_index(listint_t *head, unsigned int index...
C
/** ****************************************************************************** * @file lib_flash.c * @author Application Team * @version V4.3.0 * @date 2018-09-27 * @brief FLASH library. ****************************************************************************** * @attention * *****...
C
/********************************************** * Malloc Lab * Name : Li Pei * Andrew ID : lip **********************************************/ /********************************************** * Implemented Dynamic Memory Allocator Function: * malloc(size): Get size, add header,footer with size to get asize (al...
C
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See the LICENSE.txt file in the project root // for the license information. #include <stdlib.h> #include <math.h> #include <string.h> #include <assert.h> #include <stdbool.h> #include "flex.h" struct flex_item { #define ...
C
/*********************************************************************************** * * Author: Eric Burgos * Creation Date: October 21, 2016 * Modified Date: October 24, 2016 * Filename: tcpcli.c * Purpose: Client example for TCP Sockets; sends one string at a time * Adapted from Haviland book * **********...
C
/*---------------------------------------------------------------------------------------------- * Module: UART * * File Name: uart.h * * AUTHOR: Bassnat Yasser * * Data Created: 28 / 3 / 2021 * * Description: Header file for the UART AVR driver ----------------------------------------------------------------...
C
/* * 程序清单1-8 从标准输入读命令并执行 * */ #include "apue.h" #include <sys/wait.h> #define MAX_CMD 1024 static void sig_int(int); /* our signal-catching function. */ int main(void) { char cmd_buf[MAX_CMD] = {0}; int pid = 0; int child_status = 0; if (signal(SIGINT, sig_int) == SIG_ERR) { err_sys("signal error."); } ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* main.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> int main(void) { int T, t; scanf("%d", &T); for(t = 1; t <= T; t++) { int N; scanf("%d", &N); int A[1001], B[1001]; int i; for(i = 0; i < N; i++) scanf("%d %d", &A[i], &B[i]); int stars[1001] = {0}; int totalstars = 0; int complete...
C
Notes: Trees Trees consist of nodes (which contain values) connected by edges The hierachical ordering of our diagram conveys parent-child relationships A node can have many children, but only one parent Trees cannot contain cycles (loops) There can only be one path from each node to every other node on the tree n n...
C
/* ============================================================================ TRABALHO PRTICO 6 - Paralelismo Algoritmos e Estruturas de Dados III Bruno Maciel Peres brunomperes@dcc.ufmg.br LISTA.C - Define as funes que operam sobre o TAD lista adequado s necessidades do algoritmo ===========================...
C
/* * main.c * * Created on: June 18, 2020 * Author: Jon McKay */ #include <stdio.h> int main(void) { char characterInput1; char characterInput2; char characterInput3; char characterInput4; char characterInput5; char characterInput6; printf("Enter 6 characters: "); characterInput1 = getchar(); getc...
C
#include <pthread.h> #include <stdio.h> void *thread_func(void *a) { return NULL; } int main(int argc, char *argv[]) { size_t size; pthread_attr_t attr; pthread_attr_init(&attr); pthread_attr_getstacksize(&attr, &size); printf("Default stack size = %li\n", size); size = 32 * 1024 * 1024; p...
C
#ifndef boolean_H #define boolean_H /***********************************/ /* Program : boolean.h */ /* Deskripsi : header file modul boolean */ /* NIM/Nama : 24060119120027/Iwan Suryaningrat*/ /* Tanggal : September 2020*/ /***********************************/ //type boolean enumerasi bahasa C, false=0...
C
#include <stdio.h> int main(void) { int height,length,width,volume,weight; height=8; length=12; width=10; volume=height*length*width; weight=(volume+165)/166; printf("Dimensions:%dx%dx%d\n",length,width,height); printf("Volume(cubic inches):%d\n",volume); printf("Dimensional weight (pounds):...
C
#include <stdlib.h> #include <time.h> #include <stdio.h> int swap_count = 0; int comparation_count = 0; // Генерирует случайн int побитово беря для каждого бита последний бит rand int randint(void){ int num = 0; for (int i = 0; i < 8 * sizeof(int); i++){ num |= (rand() & 1) << i; } return...
C
#include <stdio.h> #include <wiringPi.h> #include <time.h> time_t rawtime; struct tm * timeinfo; int openDoor, openDoor1, openDoor2, openDoor3; void myInterrupt (void) { openDoor = !openDoor; if ( openDoor ) printf("Door 1 is opened..."); else printf("Door 1 is closed..."); time ( &rawtime ); tim...
C
/*************************** * PROGRAM NAME: guess.c * * PAGE NUMBER 214 * * AUTHOR: SWAROOP * ***************************/ #include <stdio.h> #include <stdlib.h> #include <time.h> #define MAX_NUMBER 100 /* external variable */ int secret_number; /* prototypes */ void initialize_number_generat...
C
/*Santiago Flores * * * FILE: AST.h * * The header file for AST.c * Creates a new struct called ASTNode which is used to create a pointer to the data structure * that is used to represent the parsed program. * ASTNode contains: * enum NODETYPE - to hold the type of node when a new node is created * enum ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* better_in_reverse.c :+: :+: :+: ...
C
#include <stdio.h> int fibo(int); int main() { int n=0; printf("Ǻġ Է = "); scanf_s("%d", &n); for (int i = 0; i < n; i++) { printf(" %d", fibo(i)); } printf("\n"); return 0; } int fibo(int n) { if (n == 0) return 0; if (n == 1) return 1; else return fibo(n - 1) + fibo(n - 2); }
C
#include <stdio.h> #include <glib.h> #include <poppler.h> #include <stdlib.h> char ESC=27; void bold_on() { printf("%c[1m",ESC); } void bold_off() { printf("%c[0m",ESC); } void find(const char *filename, GRegex *regex) { GFile *file; gchar *uri; PopplerDocument *doc; PopplerPage ...
C
#include<stdio.h> int rev(char *); int main() { char str[20]; printf("enter a string"); scanf_s("%s", str,20); rev(str); getch(); return 0; } int rev(char *a) { if (*a) { rev(a + 1); printf("%c", *a); } }
C
#include "holberton.h" /** * puts2 - takes a pointer to string and prints one char out of 2 from * the string it's pointing to, followed by a newline. * @str: pointer to a char * */ void puts2(char *str) { while (*str) { if (!(*(str + 1))) { _putchar(*str); break; } _putchar(*str); str +...
C
#include "holberton.h" /** * _strcmp - compare bytes of a string * @s1: The destination string * @s2: source string. * Return: int. */ int _strcmp(char *s1, char *s2) { int i = 0; int same = 0; int res = 0; while (same == 0 && *(s1 + i) && *(s2 + i)) { if (*(s1 + i) != *(s2 + i)) { same = 1; } else {...
C
#include "../monty.h" static int monty_print_elem(void *user_data, dlist_value_t value) { UNUSED(user_data); if ( (value.as_int > 0) && (value.as_int <= 127) ) { printf("%c", value.as_int); return DLIST_CONTINUE; } return DLIST_STOP; } void monty_instr_pstr(monty_t *monty) { dlist_apply_head_to_tail(monty->...
C
#include <stdio.h> #include <stdlib.h> int main() { int math_score = 99; int chinese_score = 90; int english_score = 88; printf("your testscore:\nmath_score:%d,chinese_score:%d,english_score:%d\n",math_score,chinese_score,english_score); return 0; }
C
void print() { int i; char *c = "hello world\n"; char d[13]; printChar('c'); printStr(c); for(i = 0; i < 13; i++) d[i] = c[i]; printChar('d'); printStr(d); printInt(25); } int main() { int cycles, insts; cycles = getTime(); insts = getInsts(); print(); cycles = getTime() - cycles; ins...
C
#include "mont_utils.h" //ADD; void ADD(uint32_t* t, uint8_t i, uint32_t C) { uint32_t W = 0xffffffff; uint32_t sum[2] = {0, 0}; while(C != 0) { if(W - C < t[i]) { sum[0] = t[i] + C; sum[1] = 1; } else { sum[0] = t[i] + C; sum[1] = 0; } C = sum[1]; t[i] = sum[0]; i += 1; } } //SUB_C...
C
#include <assert.h> #include <stddef.h> #include "hashtab.h" #include "slist.h" unsigned int hash(const char * key, unsigned int table_size) { unsigned int hash_val = 0; key++; while( *key != '\0') { hash_val = (hash_val << 5) + *key++; } return hash_val % table_size; } void hash_ta...
C
#include "dlistnode.h" DListNode *dListNode_new( Data data, DListNode *prev, DListNode *next ) { DListNode *node = (DListNode *) malloc( sizeof( DListNode )); assert( node != NULL ); node->data = data; node->prev = prev; node->next = next; return node; } void dListNode_destroy( DListNode *...
C
/* ** EPITECH PROJECT, 2018 ** PSU_42sh_2017 ** File description: ** Check the display of the prompt. */ #include <criterion/criterion.h> #include <criterion/redirect.h> #include "shell.h" #include "execution.h" #include "instruction.h" #include "mylib.h" Test(display_prompt, correct_prompt, .timeout = 0.5) { shell_...
C
#include <stdio.h> #include <stdlib.h> #include "mystrlib.h" int main() { char string1[] = "hello"; char string2[] = " world"; int match = strComp(string1, string2); printf("Match: %d\n", match); int length1 = strLen(string1); int length2 = strLen(string2); printf("Length 1: %d\n", length1); printf("Length 2...
C
// Marek Sokolowski - Computer Network large assignment problem // Master implementation (can control players over network). // // Invocation: // ./master [port-num] // // If port-num is given, sets up telnet server at this port; else seeks for a free // port and sets up server there. // // Telnet commands: // STAR...
C
/** * Driver for a SD Card * @file sd.h * @author Stefan Profanter * @author Sean Labastille */ #ifndef __SD_H__ #define __SD_H__ #include <spi/spi.h> #include <common.h> #include <drivers/display/display.h> #define CMD0 0 #define CMD1 100 #define CMD8 1 #define CMD16 2 #define CMD17 3 #define CMD24 7 #define CMD...
C
int Zero_Ex_Operator(int ref,int max); int Ex_Sy(int size,int num); int Zero_Ex_Operator(int ref,int max) { //int i;//min=0 if(ref>max-1 || ref<0) { return 0; } else { return 1; } } int Ex_Sy(int size,int num) { // For WS,WA // num :refer_point // size:(size = width or height)...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> int check_if_module_loaded(char* module) { char str[50]; char cmd_str[50]; int size = 0; int usage = 0; int rc = 0; FILE *fp = NULL; sprintf(cmd_str, "lsmod | grep %s > /tmp/lsmod.txt", module); rc = system(cmd_str); printf("%s...
C
#include<stdio.h> int main(){ int x[1000]; int i; for(i=0;i<1000;i++) { scanf("%d",&x[i]); if(x[i]==1) break; } for(i=0;i<1000;i++) { if(x[i]==1) break; printf("%c",x[i]); } return 0; }
C
/*Author Name: Balasubramanian R Github Link: https://github.com/Cyberkid2311 */ /*Ported to C by : Deepak Chauhan Github Profile: https://github.com/RoyalEagle73 */ /* The main aim of this program is to find the Number of turns made at the end and not during the process. So We count the number of Rotations mad...
C
#include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include "tree.h" int get_priority(char c) { switch(c) { case '+': case '-': return 1; case '*': case '/': return 2; case '^': return 3; } return 20; // Priority of numbers, brackets, variables, etc } Tree tree_create(Tok...
C
#include <stdio.h> #include <string.h> int main(){ int n,i; char v[100000]; scanf("%d", &n); strcpy(v,"Feliz nata"); i=9; while(n--){ v[i] = 'a'; i++; } printf("%sl!\n", v); return 0; }
C
#include <stdio.h> #include "records.h" int main(){ int i; /* ask user what he wants to know choices include: winning seasons (above .500) losing seasons (below .500) seasons with 10 or more wins undefeated seasons seasons with equal wins and losses bowl eligible seasons */ int response;//for gathering...
C
/* * tape2disk.c * * MPX uses 2 EOF in a row to separate sections of MPX3.x master SDT tapes. * It uses 3 EOF in a row to indicate the EOT on MPX 3.X tapes. So we * cannot assume EOT is at the 1st or 2nd EOF in a row. We keep looking * for a third one. For user SDT tapes or MPX 1.X master SDT tapes use ...
C
// $Id: rint.c 1.2 2009/01/13 08:47:50EST 729915 Development $ // // Math functions from GNU compiler. #pragma once #include "gnumath.h" /// <summary>Rounds to the nearest integer by adding 0.5 to a double /// or floating point number and casting to an integer, truncating the /// decimal.</summary> /// //...
C
/* main.c --- * * Filename: main.c * Description: Lab 4, word count * Author: Michael McCann: mimccann * Partner: Samuel Carter: sambcart * Maintainer: Michael McCann * Created: 02/02/17 * Last-Updated: 02/09/17 * By: Michael McCann * Update #: 1 * */ /* Change log: * Added comments * ...
C
# include <stdio.h> # include <sys/time.h> # include <unistd.h> # include <sys/types.h> # include <stdlib.h> # include <sys/wait.h> # include <pthread.h> # define amount 100000000 static int arr[amount]; static int a = 50, ans; // static int count = 0; static int thread_num = 10; static int i_create; static int i_...
C
/* * Delta programming language */ #include "DeltaCompiler.h" #include "delta/macros.h" #include "delta/structs/DeltaClass.h" struct DeltaCompiler* new_DeltaCompiler(int total_objects) { struct DeltaCompiler *c = (struct DeltaCompiler*) malloc(sizeof(struct DeltaCompiler)); int i; c->alloc_functions = DELTA_...
C
#include <stdio.h> #include <stdlib.h> int main() { int arr1[] = { 3, 5, 38, 44, 47 }; int arr2[] = { 3, 44, 38, 5, 47 }; int arr3[] = { 2, 15, 26, 27, 36 }; int arr4[] = { 15, 36, 27, 2, 26 }; printf("--> urutan arr1 benar %d\n",cek_urut(arr1, 5)); printf("--> urutan arr2 salah %d\n",cek_uru...
C
#include <stdio.h> void clear(){ while(getchar()!='\n'); } int main(void){ int input; int returnFromScanf; printf("enter a number: "); returnFromScanf=scanf("%d",&input); while(returnFromScanf!=1){ clear(); printf("enter a number: "); returnFromScanf=scanf("%d",&input); } printf("you entered...
C
/***************************************************************************** * Program Description: The client side of a chat app implemented in C. The * user on this end takes turns sending messages to server side. This * program takes 2 arguments on the command line: the host name and port * number, in th...
C
#include <stdio.h> #include <stdlib.h> int arr[8] = { 3,4,6,1,2,10,9,8 }; // 보조 함수 void printAll(int len , int target[]){ if(len <= 0) { printf("{ }"); } else{ printf("{"); for(int i = 0 ; i < len ; i++){ printf(" %d " , target[i]); if(i < len-1){ printf(","); } } printf("}\n"); } } void printA...
C
/* * utilsQuestions.c * * Created on: 21/06/2014 * Author: jvidiri */ #include "utilsQuestions.h" int acertos; /* * Questões e suas respostas. * */ static const questions_t const pxQuestions[] = { {"1) What is Friendster?","a) A brand. ","b) A city. ","c) A social network.","d) A game...
C
#include <stdio.h> #include <stdlib.h> int a[4000], b[4000], c[4000], d[4000]; int m1[16000000], m2[16000000]; int mycmp(const void* a, const void* b){ return *(int *)a-*(int *)b; } int main(){ int n; scanf("%d", &n); for (int i=0; i<n; i++){ scanf("%d", &a[i]); scanf("%d", &b[i]); scanf("%d", &c[i]); ...
C
/* * OpenBOR - http://www.LavaLit.com * ----------------------------------------------------------------------- * Licensed under the BSD license, see LICENSE in OpenBOR root for details. * * Copyright (c) 2004 - 2009 OpenBOR Team */ #include "Lexer.h" #include <stdio.h> #include <stdlib.h> #include <s...
C
#if 0 #include <sys/kprintf.h> #include <sys/kmalloc.h> extern uint64_t virtualMemoryAvailable; void KMALLOC_TEST(){ kprintf("Available virtual mem %p\n", virtualMemoryAvailable); kprintf("size of int %d\n", sizeof(int)); uint64_t* intmem = kmalloc(4096*2); for (int i = 0; i < 512+512; ++i) { intmem[i...
C
/* Ingresar datos de alumnos. nota(int) sexo(char)- f/m Indicar si el mejor promedio pertenece a f o m. (Utilizar switch) */ #include <stdio.h> int main () { char s,f; int i, nota, acumulador_f = 0, contador_f = 0, acumulador_m = 0, contador_m = 0, promedio_f = 0, promedio_m = 0; for...
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
/* ** EPITECH PROJECT, 2020 ** my_compute_power_rec.c ** File description: ** 02/10/2020 */ #include "my.h" int my_compute_power_rec(int nb, int p) { if (p > 0) return (nb * my_compute_power_rec(nb, p - 1)); else if (p < 0) return 0; else return 1; }
C
// // Queue.h // Tree // // Created by Sutej Kulkarni on 03/08/20. // Copyright © 2020 Sutej Kulkarni. All rights reserved. // #ifndef Queue_h #define Queue_h #include <stdio.h> #include <stdlib.h> struct tree_node { struct tree_node *lchild; int data; struct tree_node *rchild; }; struct qu { in...
C
/* */ /* Program Name: clrscr.c */ /* */ #include <conio.h> void main(void) { clrscr(); gotoxy(35,13); cputs("Hi! Borland"); gotoxy(28,25); cputs("Press any key to clear screen"); getch(); clrscr(); gotoxy(28,24); cputs("The screen has been clea...
C
#include <stdio.h> int main(void) { const int RANGE = 10; int i, n; printf("Enter an integer: "); scanf("%d", &n); i = n; while (i <= RANGE + n) printf(" %d", i++); putchar('\n'); }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #define N_TAREFAS 1000 // Numero de tarefas no saco de trabalho #define TAM_TAREFA 25000 // Tamanho de vetor a ser organizado pelos nodos void initialize_matrix(int matrix[N_TAREFAS][TAM_TAREFA]) { int i,j; for(i=0; i<N_TAREFAS; i...
C
#include <LPC17xx.h> void delay(unsigned int); // for delay int main(void) { unsigned int i, j, valueSet; SystemInit(); SystemCoreClockUpdate(); valueSet = 0; // GPIO Configuration LPC_PINCON->PINSEL0 &= 0xFF0000FF; // FIODIR Configuration LPC_GPIO0->FIODIR |= 0x0FF0; while (1) { for (i = 0; i < 8; i++...
C
# include <stdio.h> # include <libmill.h> void f(int index, const char *text) { printf("Worker %d, Message %s\n", index, text); } int main(int argc, char **argv) { char str[10]; for(int i=1;i<=100000; i++) { sprintf(str, "Text %d", i); f(i, str); } return 0; }
C
#include <stdio.h> char data[12][12]; int win (int n) { int i,j; for(i=1;i<=n;i++) { for(j=1;j<=n;j++) { if(data[i][j]!=' ') { return 0; } } } return 1; }
C
void main() { int a[20]; int size,first=-1,last=size,n=1,num; printf("enter the size of the stacks"); scanf("%d",&size); while(n!=0) { printf("press 1 for insertion in stack 1\n"); printf("press 2 for insertion in stack 2\n"); printf("press 3 for deletion in stack 1\n"); printf("press 4 for deletion in stack 2\n"); p...
C
/* * Ideas for screen management extension to EGL. * * Each EGLDisplay has one or more screens (CRTs, Flat Panels, etc). * The screens' handles can be obtained with eglGetScreensMESA(). * * A new kind of EGLSurface is possible- one which can be directly scanned * out on a screen. Such a surface is created with ...
C
/**************************************************************************** ***** ***** ***** formHandler.c ***** ***** ***** ****************************************************************************/ #include "Vk.h" /**** Local Includes ****/ #include "stdcurses.h" #include "keys.h" #inclu...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_otherutils.c :+: :+: :+: ...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include "key_seq.h" typedef struct key_seq_item KeySeqItem; struct key_seq_item { char *key; KeySeqItem *next; }; KeySeqItem *new_key_seq_item(char *key) { KeySeqItem *ksi = malloc(sizeof *ksi); ksi->key = strdup(key); ksi->next = NULL; return...
C
/* * buffer.c * * Created on: Apr 10, 2016 * Author: HaoranFang */ #include "buffer.h" void CircBuf_init(CircBuf_t *cb, size_t size, size_t item_size){ cb->buffer = malloc(size * item_size); cb->buffer_end = (char *)cb->buffer + size * item_size; cb->size = size; cb->item_size = item_siz...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> int main(void) { long * array_a; long * result; int size = 5; array_a = malloc(size * sizeof(long)); memset(array_a, 4, size * sizeof(long)); // allochiamo lo spazio di memoria per la copia result = malloc(size * sizeof(long)); ...
C
#include"stdio.h" #include"string.h" int main(){ FILE* fp = fopen("myfile","r"); if(!fp){ printf("fopen error !\n"); } char buf[1024]; const char* msg = "hello bit!\n"; while(1){ size_t ret = fread(buf,1,strlen(msg),fp); if(ret > 0){ buf[ret] = '\0'; printf("%s",buf); } if(feof(fp)){ ...
C
#define CROSSLOG_TAG "hexdump" #include <crosslog.h> #include <stdio.h> #include <stdarg.h> #include <stdint.h> #ifndef ARRAY_SIZE #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #endif #ifndef MIN #define MIN(a, b) (((a) < (b)) ? (a) : (b)) #endif static inline int local_isprint(int c) { return ((c >= 0x20)...
C
#include "tag.h" void TAG_init(TAG *this) { memset(this->name, 0, TAG_NAME_SIZE); this->favs = 0; this->tags = NULL; this->tc = 0; } int TAG_findTag(TAG *this, TAG t) { int i; for(i = 0 ; i < this->tc ; i++) { if(strcmp(this->tags[i].name, t.name) == 0) { return i; } } return -1; } void TAG_rea...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* libft.h :+: :+: :+: ...
C
/* * File: tpmeta1.c * Author: rodrigo * * Created on 24 de Outubro de 2018, 15:54 */ #include <stdio.h> #include <stdlib.h> #include "medit_defaults.h" #include "server_defaults.h" #include <string.h> #include <ctype.h> #include <unistd.h> #include <sys/stat.h> #include <fcntl.h> #include <sys/select.h> #inc...
C
#include <avr/io.h> #include <util/delay.h> //define pins #define PIN_LED1 PB0 #define PIN_LED2 PB1 //define delay time #define DELAY_MS 250 //write high #define D_HIGH(prt, pn) prt |= (1<<pn) //write low #define D_LOW(prt, pn) prt &= ~(1<<pn) //long delay, 8 bit timer protect, max 10 void long_delay_ms(uint16_t ms)...
C
/* super basic shell - starting point we can build off (using std functions) */ #include "simpleshell.h" /** * main - main for simple shell * @ac: number of arguments * @av: array of pointers to strings containing arguments passed * @env: environmental vars being passed to shell * * Return: status */ int main(i...
C
#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> #include "lib/xalloc.h" #include "lib/contracts.h" #include "lib/bitvector.h" #include "board-ht.h" #include "lib/queue.h" #include "lib/hdict.h" #include "lib/boardutil.h" // Abbreviation for lazyness typedef struct board_data bd; void ...
C
/* Name : Huong Truong * Class : CSCI 2240-003 * Program # : 3 * Due Date : Oct 24 2016 * * Honor Pledge: On my honor as a student of the University * of Nebraska at Omaha, I have neither given nor received * unauthorized help on this homework assignment. * * NAME: Huong Truong * EMAIL: httruong@unomaha.edu ...
C
#include <stdint.h> #include "Skribist.h" /* So as it turns out, these first three naive macros are actually faster than any bit-tricks or specialized functions on amd64. */ #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) #define gabs(x) ((x) >= 0 ? (x) : -(x)) #define floorf(x)...
C
#include <stdio.h> void main(void) { FILE *fp; fp = fopen("c:\\file.txt", "w+"); if(fp == NULL) { puts("파일을 생성할 수 없습니다."); } else { printf("파일 포인터의 위치 : %d\n", ftell(fp)); fputs("abcde", fp); printf("파일 포인터의 위치 : %d\n", ftell(fp)); rewind(fp); ...
C
/***************************************************************************************************/ /* */ /* Copyright (C) 2004 Bauhaus University Weimar */ /* Released in...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> #include <stdbool.h> #define DIM 30 #define OVERFLOW_SUM_COND (op2 > 0 && (op1 > INT_MAX - op2)) || (op2 < 0 && (op1 < INT_MIN - op2)) #define OVERFLOW_SUBTRACT_COND (op2 > 0 && (op1 < INT_MIN + op2) ) || (op2 < 0 && op1 > INT_MAX + op2) ...