language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <stdlib.h> #include <cs50.h> typedef unsigned char byte; byte getRed(int color); byte getGreen(int color); byte getBlue(int color); int main(int argc, string argv[]) { if (argc != 2) { printf("usage: ./rgb number\n"); return 1; } int color = atoi(argv[1]); ...
C
#include <stdio.h> #include <stdlib.h> #define CANTIDAD_NUMEROS_ALEATORIOS 10 #define TOPE_SUPERIOR 180 #define TOPE_INFERIOR 4 int main(int argc, char *argv[]) { int numero_aleatorio, semilla, vector_numeros[CANTIDAD_NUMEROS_ALEATORIOS]; int vector_numeros_copia[CANTIDAD_NUMEROS_ALEATORIOS], suma_aux; // Inic...
C
/* Una señal discreta es un conjunto de valores tomados de forma equidistante a partir de una señal continua a intervaos fijos de tamaños Ts Ts= Es el periodo de muestreo */ #include <stdio.h> #include "archivos.h" #include "procesamiento.h" #include <math.h> #include <stdlib.h> int main(int argc, char const *argv[]...
C
#include "PID.h" void PID_Initialize(PID_Controller * _PID) { // Init all values to zero _PID->sampleError = 0.0f; _PID->deltaInput = 0.0f; _PID->lastError = 0.0f; _PID->PTerm = 0.0f; _PID->ITerm = 0.0f; _PID->DTerm = 0.0f; _PID->controllerOutput = 0.0f; _PID->updates = 0; } double PID_Up...
C
#include <stdio.h> #include <stdlib.h> #define MAX_STRING 50 int main() { int numero; printf("Ingrese el numero de caracteres:"); scanf("%d", &numero); numero -= 1; char palabra[numero]; printf("Ingrese la palabra:"); scanf("%s", &palabra); int i; int j = 0; for(i=0; i<=numero;i...
C
#include <stdio.h> add(int n); int main() { int n, sum; printf("\n\n\t*Welcome! to Akash Addition Calculator*\n\n"); printf("______________________________________________________\n\n"); printf("Enter the number you want the sum of: \n"); scanf("%d", &n); sum = add(n); printf("The sum of the...
C
#ifndef _CLOCK_TIMER_H #define _CLOCK_TIMER_H #include <sys/time.h> #define BILLION 1000000000L /* The argument now should be a double (not a pointer to a double) */ #define GET_TIME(now) { \ struct timespec time; \ clock_gettime(CLOCK_MONOTONIC, &time); \ now = time.tv_sec + time.tv_nsec/100000000...
C
//#include "list.h" //#include <stdio.h> //#include <stdlib.h> //#include "coordinate.h" /* * Output: * Returns a newly allocated List * Summary: * Allocates space for an empty new List and returns it */ List* ConstructList() { List* result = (List*) malloc(sizeof(List)); if (result != (List*)...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include<assert.h> #define MAX_CHARACTERS 1005 #define MAX_PARAGRAPHS 5 int COUNT = 1; char** split_string(char* s, char d); void print_char_array(char**); char* strip(char*); char* kth_word_in_mth_sentence_of_nth_paragraph(char**** document, int k, int m, i...
C
// // menuTest.c // AnalyserDude // // Created by Peter Shaw on 3/9/13. // // #include <stdio.h> #include "../cu/cu.h" #include "../../src/ui/menu.h" static void dummy(void){} TEST(test1) { assertTrue(1); printf("MenuTest test\n"); assertEquals(1, 1); } TEST(test_init_menu) { ui_menu_init(); ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "common.h" #include "utils.h" #include "sym.h" #include "types.h" #include "instance.h" #include "absyn.h" #include "table.h" InstanceVar *newInstanceVar(Sym* name, InstanceVar *next, Sym *className, Sym *fileName, int offset) { Instanc...
C
#include "log.h" #include <stdio.h> #include <stdarg.h> void log_it(const char * prefix, const char * fmt, ...) { fprintf(stderr, "%s: ", prefix); va_list args; va_start(args, fmt); vfprintf(stderr, fmt, args); va_end(args); fprintf(stderr, "\n"); }
C
#include "Filter.h" //==================================================================== // 初始化上升沿滤波。 //==================================================================== void InitPosEdge ( tPosEdge * A_pPosEdge, U1 A_bIn ) { A_pPosEdge->last = A_bIn; } //===============================================...
C
/* Auther : Heinz Samuelsson Date : 2013-04-14 File : thread_test1.c Reference : https://computing.llnl.gov/tutorials/pthreads/#Overview Description : Test of threads and function calls. */ #include <stdio.h> // standard I/O routines #include <stdlib.h> // exit functions ...
C
#include<stdio.h> #include<string.h> /*A program that defines a structure employee containing the details such as empno, empname, department name and salary. The structure has to store 20 employees in an organization. Use the appropriate method to define the above details and define a function that will display the co...
C
// // System accessor functions for the Printer Application Framework // // Copyright © 2020-2023 by Michael R Sweet. // // Licensed under Apache License v2.0. See the file "LICENSE" for more // information. // // // Include necessary headers... // #include "system-private.h" #ifdef HAVE_LIBJPEG # include <jpeglib....
C
// // main.c // CPULab // // Created by Maor Zeevi on 6/16/19. // Copyright © 2019 Meir Zeevi. All rights reserved. // #include "oslabs.h" #include <stdio.h> #include <string.h> struct PCB handle_process_arrival_pp(struct PCB ready_queue[QUEUEMAX], int *queue_cnt, struct PCB current_process, struct PCB new_proces...
C
#include <Windows.h> #include <stdlib.h> #include <stdio.h> int main() { //Variables stockage Disque BOOLEAN bSuccess; HANDLE hs = GetStdHandle(STD_OUTPUT_HANDLE); char espace[30]; DWORD written = 0; DWORD lpSectorsPerCluster; DWORD lpBytesPerSector; DWORD lpFreeClusters; DWORD lpTotalClust...
C
#include <assert.h> #include "builtin.h" static const struct builtin_meta BUILTIN_META_TABLE[] = { [BUILTIN_READ] = { .name = "READ" }, [BUILTIN_EVAL] = { .name = "EVAL" }, [BUILTIN_DOT] = { .name = "." } }; const struct builtin_meta * get_builtin_meta(enum builtin builtin) { assert(BUILTIN_READ <= builtin); a...
C
//Write a removeDuplicates() function which takes a list and deletes //any duplicate nodes from the list. The list is not sorted. // //For example if the linked list is 12->11->12->21->41->43->21, //then removeDuplicates() should convert the list to 12->11->21->41->43. // //Challenge //O(n) time //12 11 12 21 41 43 21 ...
C
// //This app captures the background as a difference matte, after this //it subtracts this matte from the frames and quantizes, displaying a //silhouette of the moving spectator. // #include <stdio.h> #include <stdlib.h> #include <string.h> #include "ledmirror.h" #include "utils.h" #include "animation.h" ...
C
// exp function demo program #include "stdio.h" #include "math.h" main() { printf("%g \n" , exp(1)); // e ^ 1 = 2.71828 printf("%g \n" , exp(2)); // e ^ 2 printf("%g \n" , exp(-2)); // e ^ -2 printf("%g \n" , exp(0)); // e ^ 0 = 1 } // where e value is 2.71828
C
#include "woody_woodpacker.h" #include <elf.h> #include <assert.h> struct e_ident *parse_ident(STREAM *file) { struct e_ident *e_ident; char magic[4] = {ELFMAG0, ELFMAG1, ELFMAG2, ELFMAG3}; if (!(e_ident = sread(file, 0, EI_NIDENT))) return NULL; FT_DEBUG("EI_NIDENT system value is: %u.\n", EI_NIDENT); asser...
C
#include <stdio.h> #define MAX 10000 #define NONE -1 struct Node { int parent; int left; int right; }; struct Node Tree[MAX]; void pre_parse(int u) { if (u == NONE) { return; } printf(" %d", u); pre_parse(Tree[u].left); pre_parse(Tree[u].right); } void in_parse(int u) { ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* list_formats_pcs.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "new_lexan.c" #define MAX 200 char str[30]; Token lookahead; Token tkns[MAX]; int tkn_count = 0; int start = 0; Token genToken(){ return tkns[start++]; } void T(); void E(); void E(){ lookahead = genToken(); if(strcmp(lookahead.type, "...
C
#include <stdio.h> int main() { int array[][3]= {{1, 2, 3}, {4, 5, 6}}; int (*p)[3] = array; for(int i = 0; i < 2; i++) { for(int j = 0; j < 3; j++) { printf("%p ",&p[i][j]); } printf("\n"); } printf("p = %p\n", p); printf("array = %p\n", array); printf("*p = %p\n", *p); printf("*array = %p\n",...
C
#include <stdio.h> #include <stdlib.h> #include <stdint.h> #include <inttypes.h> #include <cuda_runtime.h> #include <sys/time.h> #include "aio.h" #define a(i, j) ((i)*s+(j)) #define b(i, j) ((i)*s+(j)) #define c(i, j) ((i)*s+(j)) void mmul(uint64_t s) { int i, j; int *A_h, *A_d; int *B_h, *B_d; int *C_h, *C_d; v...
C
#include <stdio.h> float f=1.11; double d=3.14; char s[] = "2.22,1.234567"; int main() { sscanf(s, "%f,%lf", &f, &d); printf("f=%f, d=%lf\n", f, d); return 0; } #ifndef __NO_SYSTEM_INIT void SystemInit() {} #endif
C
#include <stdio.h> #include <stdbool.h> /* In this demo, we'll recap our operators learning by building a simple program that modifies employee salary with a bonus/pay increase following a particularly good year of sales. If an employee earns less than £30,000, then they are entitled to a 1.15% ...
C
#include <stdio.h> #include <stdlib.h> #include <locale.h> #include <math.h> #include <conio.h> #include <time.h> #include <string.h> #include <ctype.h> #include <time.h> #define LINHA 5 #define COLUNA 3 #define TAM 10 #include "FUNCAO.h" FILE *MENU (FILE *log) { FILE *arquivo; arquivo = fopen("01-08-2021.lo...
C
/************************************************** Program to input Employee details using structures BY SAMARTH C SHETTY USN 1BM19CS141 **************************************************/ #include <stdio.h> #include <conio.h> #include <string.h> int main() { struct Employee { char name[100]; ...
C
#include <sys/socket.h> #include <sys/types.h> #include <netinet/in.h> #include <netdb.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <arpa/inet.h> #include<pthread.h> typedef struct { double rectX; double rectY; double headCenterX; double ...
C
#include "queue.h" #include <stdio.h> #include <stdlib.h> void queue_create(Queue *q) { q->front = 0; q->position = MAX_SIZE - 1; q->size = 0; } int queue_push(Queue *q, int val) { if (queue_full(q)) return QUEUE_IS_FULL; q->position = (q->position + 1) % MAX_SIZE; q->data[q->position...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <sys/fcntl.h> #include <wiringPi.h> #include <lcd.h> #include <time.h> #define COLUMNS 16 #define LCD_RS 3 #define LCD_E 14 #define LCD_D4 4 #define LCD_D5 12 #define LCD_D6 13 #define LCD_D7 6 #define LCD_RS 3 int lcd; int ma...
C
#include <stdio.h> #include <string.h> //arsip beruntun tanpa pencarian typedef struct { char nim[10]; char nama[100]; char nilai[2]; }nilaiMatkul; int main(int argc, char const *argv[]) { nilaiMatkul rekaman; FILE *arsipMatkul; arsipMatkul = fopen("ArsipMatkul.dat", "r"); printf("Isi arsip...
C
#include "scanner.h" int get_token(){ char caracter; int posicion = 0; do{ caracter = getchar(); }while(isspace(caracter)); switch (caracter){ case EOF: return FDT; break; case ',': buffer[0] = caracter; buffer[1] = '\0'; return SEP; ...
C
/* This file is a portion of the original code supplied by Altera. It has been adapted by N. Manjikian for use in ELEC 371 laboratory work. Various unnecessary or extraneous elements have been excluded. For example, declarations in C for external functions called from asm() instructions are not...
C
/* ** EPITECH PROJECT, 2021 ** B-CPE-200-BER-2-1-matchstick-mickael.riess ** File description: ** play_a _round_after_checks */ #include <stdio.h> #include <stdlib.h> #include "include/matchstick.h" #include "include/my.h" void apply_player_move(matchstick_board *game) { my_putstr("Player removed "); my_put_n...
C
#pragma warning(disable:4996) #include <stdio.h> #include <stdlib.h> //Multi thread //#include <pthread.h> //For doing a thread. //#include <unistd.h> //For using usleep. //Socket #include <stdio.h> #include <sys/types.h> //#include <sys/socket.h> //#include <netinet/in.h> //#include <netdb.h> #includ...
C
#include <stdio.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> int main() { int sd, newsd; char buffer[1024]; struct sockaddr_in servAddr; struct sockaddr_storage serverStorage; socklen_t addr_size; sd = socket(PF_INET, SOCK_STREAM, 0); serverAddr.sin_family = AF_INET; serverAddr.sin...
C
// Name: Rodrigo Ignacio Rojas Garcia // Course Number: ECE 2230 // Section: 001 // Semester: Spring 2017 // Assignment Number: 3 // © Rodrigo Rojas. All Rights Reserved. // Bug: Once the program reaches a request_counter of 27989, the program starts leaking for unkown reason // Library Declaration Section #include...
C
#include <assert.h> #include <stdio.h> #include "vulkan.h" #include "swapchain.h" static uint32_t get_min_image_count(VkPhysicalDevice physical_device, VkSurfaceKHR surface) { VkSurfaceCapabilitiesKHR capabilities; vk_get_physical_device_surface_capabilities_khr(physical_device, surface, &capabilities); r...
C
#include <p24FJ64GB002.h> #include <stdio.h> #include <stdlib.h> #include "DogM.h" // Defining player perspective directions #define NORTH 1 #define EAST 2 #define SOUTH 4 #define WEST 8 void turnLeft(); void turnRight(); void forward(); void drawArea(unsigned int x, unsigned int y, unsigned int length, unsigned int ...
C
/** * Copyright (c) 2016 BitCoding */ #ifndef CCTALK_HOST_H #define CCTALK_HOST_H 1 // #define CCTALK_WRITEDEBUG 1 // #define CCTALK_READDEBUG 1 #include <cctalk/core/global.h> #include <cctalk/core/tty.h> /*Host*/ struct cctalk_host { /* Serial Interface. */ struct cctalk_tty* tty; /* Host identif...
C
#include <stdio.h> #include <stdlib.h> // nesting if basically makes program more interactive // taking example of if statement , we we have done previous time , please check it out if you haven't seen it. int main() { int age; int gender; //if you are using or any other softwere for c , just left one...
C
#include<stdio.h> void main() { int a[100],n,s,i; printf("Specify Number of Elements To Be Stored:"); scanf("%d",&n); printf("Enter the elements to be stored:"); for(i=0;i<n;i++) scanf("%d",&a[i]); printf("Enter the position from which it is to be deletd:"); scanf...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> int main() { char *s1 = malloc(sizeof(char) * 61); scanf("%s", s1); char *ptr = strtok(s1, "."); while (ptr != NULL) { printf("%s\n", ptr); ptr = strtok(NULL, "."); } return 0; }
C
#include<stdio.h> #include<stdlib.h> #include<memory.h> #include<string.h> int token; //current token char *src, *old_src; //pointer to source code string int poolsize; //default size of text/stack/data int line; //line number int *text, //text segment *old_text, //for dump text segment *stack; //s...
C
#include <stdio.h> #include <stdlib.h> //Software Engineer Name: Kariman Karam //All inputs are unsigned character /* - Define your global variables if needed here: actual_result expected_result - Please concider the memoery optimization. */ /* - Define your functional prototypes used here: sum unittest - Please ...
C
#include "holberton.h" /** * print_times_table - print times tables. * *@n:is a number * Return: On succes print times table. * On error, dont return times table. */ void print_times_table(int n) { int i, j, mult, m; if(n < 15 && n > 0) { for (i = 0; i <= n; i++) { for (j = 0; j <= n; j++) { mult = i...
C
#include <stdio.h> #include <stdlib.h> void print_hex(char* buffer, int length){ int i; for(i=0; i<length; ++i){ printf("%hhX ", buffer[i]); } printf("\n"); } typedef struct virus { unsigned short length; char name[16]; char signature[]; } virus; void print_virus(virus* v){ ...
C
#include <stdio.h> #include <stdlib.h> #define MAXLEN 14 #define MAX_STACK_SIZE 100000 #define MAX 455 #define MALLOC(p,s)\ if(!((p)=malloc(s))){\ fprintf(stderr,"Insufficient memory");\ exit(EXIT_FAILURE);\ } char* make1darr(int n){ char *x; MALLOC(x,n*sizeof(*x)); return x; } char*...
C
#include "resource_table_empty.h" #include "pru.h" #include <stdint.h> #define P9_31 0 volatile register uint32_t __R30; volatile register uint32_t __R31; uint8_t *shared_memory = (uint8_t*)(0x10000); // TODO: multiple channels/pins // E.g. ws281x(0xFF00FF, P9_31) void write_ws281x(uint32_t pixel, int pin) { ...
C
/* ** EPITECH PROJECT, 2019 ** MUL_my_defender_2018 ** File description: ** combat */ #include "my_defender.h" static void manage_collision(game_t *game, entity_t *ally, entity_t *enemy) { if (ally->type == 'b' && enemy->type != 'b') ally->life--; else if (ally->type != 'b' && enemy->type != 'b') { ...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #define Tam 5 void inicializa(int matriz[Tam][Tam]){ srand(time(NULL)); int num_rnd; for (int j=0;j<Tam;j++){ for (int i=0;i<Tam;i++){ num_rnd=3+(rand()%13); matriz[i][j]=num_rnd; } } } int main(){ int matriz[Tam][Tam]; inicializa(matriz); for (...
C
/* *代码作用:确定主机字节序程序 */ #include <stdio.h> #include <arpa/inet.h> int main(int argc, char *argv[]) { int a = 0x01020304; short int b = 0x0102; union { short s; char c[sizeof(short)]; }un; un.s = 0x0102; if( (un.c[0] == 1)&& (un.c[1] == 2)) { printf("big-endian\n"); } else if((un.c[0] == 2) && (un.c[1...
C
#include <SDL2/SDL.h> #include <SDL2/SDL2_gfxPrimitives.h> #include <stdio.h> #include <stdbool.h> #include "Headers\Init.h" #include "Headers\Header.h" void init() { int SCREEN_WIDTH = 960; int SCREEN_HEIGHT = 540; //!ISDL inicializalasa if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 ) { printf( "Nem sikerult...
C
#include <stdio.h> int main(void) { int n,k,i,l; scanf("%d %d",&n,&k); if(n>k) {l=n; } else { l=k; } for(i=l;i>=2;i--) { if(n%i==0 && k%i==0) { printf("%d\n ",i); }} return 0; }
C
#include <stdio.h> void print_binary(int number) { if (number) { print_binary(number >> 1); putc((number & 1) ? '1' : '0', stdout); } } unsigned short swap_bytes(unsigned short i) { return ((0x0ff & i) << 8) | ((0xff00 & i) >> 8); } int main(void) { unsigned short x = 0x1234; // 0001...
C
#ifndef _REENTRANT #define _REENTRANT #endif #include <stdlib.h> #include <stdio.h> #include <pthread.h> #include <semaphore.h> #include <unistd.h> #include <time.h> #define TRUE 1 #define FALSE 1 #define MAX_WORMS 128 #define MAX_BABY 7 sem_t empty, refill, wormlock; int worms; void* Parent(void* arg); void* Baby(v...
C
#include "iodefine.h" // portA LED #define LED_IO PORTA.PDR.BYTE #define LED PORTA.PODR.BYTE void turnOnLed(char status); void turnOnAllLed(); void turnOffAllLed(void); void initLed() { LED_IO = 0xff; } void turnOnAllLed(void) { turnOnLed(0xff); } void turnOffAllLed(void) { turnOnLed(0x00); } void turnOnLed(...
C
#include<stdio.h> float main() { float a,b,c; printf("key in the first number"); scanf("%f", &a); printf("key in the second number"); scanf("%f", &b); c=a+b; printf("The input value of a = %f\n",a); printf("The input value of b = %f\n",b); printf("The output value of c after addition of a & b = %f\n",c); }
C
#include <stdio.h> #include <mpi.h> #define SENDER 0 #define RECEIVER 1 int main (int argc, char **argv) { // rank = id-ul procesului // proc = numarul de procese int rank, proc, a; // initializam procesele MPI_Init(&argc, &argv); // fiecare proces are un rank MPI_Comm_rank(MPI_C...
C
/* * This file is part of the ESIZON distribution. * Copyright (c) 2020 Ruben Cordero Ramos. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3. * * This program i...
C
#include <stdio.h> struct stu_info { char name[41]; long int id; char dept[16]; short int class; float gpa; }; void setInfo(struct stu_info s[], int size) { int i; for(i=0;i<size;i++){ printf("%d-th student\nEnter name:",i+1); scanf("%s",s[i].name); printf("\nEnter id:"); scanf("%ld",&s[i]...
C
//---------------------------------------------------------- // I2C用関数 by Takuya Matsubara //---------------------------------------------------------- #include <avr/io.h> char i2c_wait(void); void i2c_start(); void i2c_stop(); void i2c_writebyte(unsigned char dat); unsigned char i2c_readbyte(char noack); ...
C
#include <stdio.h> #define PI 3.14159 int main(void) { double radius; printf("Enter radius: "); scanf("%lf", &radius); printf("volume is: %lf \n\n", 4.0*PI*radius*radius*radius/3.0); return 0; }
C
/* * ===================================================================================== * * Filename: even_odd.c * * Description: determine if value is even or odd * * Version: 1.0 * Created: 01/24/2019 09:36:37 AM * Revision: none * Compiler: gcc even_odd.c -o even...
C
#include<stdio.h> #define gc getchar_unlocked int find() { char c=gc(); while(c<'0'||c>'9') c=gc(); int count=0; while(c>='0'&&c<='9') { if(c=='4') count++; c=gc(); } return count; } int main() { int t,d; char ch; scanf("%d",&t); while(t--) { printf("%d\n",find()); } return 0; }
C
#include "init.h" #include <SDL.h> void Game_init(int width, int height, SDL_Window **pwindow, SDL_Renderer **prenderer, HandList *hand, TTF_Font **font, t_board board[15][15], t_Stones *Stones, previous_step *rst, int *RandTable, HandPosition *posOfHands, int *prev){ //Initializing o...
C
#include <stdio.h> #include <pthread.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include "crc8.h" #include "cJSON.h" int port = 8083; char HOST[] = "127.0.0.1"; void *do_work(void *p) { int sock_fd; sock_fd = socket(AF_INET, SOCK_STREAM, 0); struct sockaddr_in srv; srv.sin_family ...
C
#include <stdio.h> int main(void){ int p1, p2; printf("Media das provas >>>>>>>>\n"); printf("Digite a nota da Prova 1: "); scanf("%d", &p1); printf("Digite a nota da Prova 2: "); scanf("%d", &p2); printf("A nota media e %d\n", (p1+p2)/2); return 0; }
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_itoa_base.c :+: :+: :+: ...
C
#include<stdio.h> #include<conio.h> void main() { int x,y,z,a,b; clrscr(); printf("enter the value of x,y,z"); scanf("%d%d%d",&x,&y,&z); a=((x+y).z)) b=(x.y)+(y.z) printf("\n value of a=%d",a); printf("\n value ofb=%d",b); getch(); }
C
/** * Filename: debug.h * Author: Alexandru Mosoi (brtzsnr@gmail.com) * Last modified: 07 March 2008 * * Documentation: * * This module offers students some simple C macros meant to facilitate * treating errors and debugging. Messages will be printed to stderr and * will contain, alongside user's message, file...
C
#include "bashniclient.h" #include "board_representation.h" int got_signal = 0; node_t board[32]; node_t moves[32]; void init_moves(){ for(int i = 0 ; i< 32; i++){ if(moves[i].next != NULL){ node_t* temp = moves[i].next; while(temp != NULL){ node_t* next_node = tem...
C
#include <iostream> #include <stdio.h> #include <stdlib.h> #define BLOCK_SIZE 1024 #define MAX_MASK_WIDTH 5 #define TILE_SIZE 1024 __constant__ int M[MAX_MASK_WIDTH]; using namespace std; __global__ void ConvolutionBasic(int *N,int *M,int *P,int Mask_Width,int Width){ int i = blockIdx.x*blockDim.x + threadIdx.x; ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "btree.h" #include "ascii_tree.h" /* * 1. leaks -atExit -- ./a.out | grep LEAK * we use the above command to detect memory leak. */ BTree* create_node(int data) { BTree* tmp = (BTree*) calloc(1, sizeof(struct tree_node)); if(!tmp) ...
C
#include<stdio.h> void binaryofnum(int ); #define BITS sizeof(int)*8 int main(void){ unsigned int num,msb; printf("enter a number \n"); scanf("%u",&num); binaryofnum(num); msb=1<<(BITS-1); if(num&msb) printf("msb of %d is set",num); else printf("msb of %d is not set",num); return 0; } void binaryofnum(int ...
C
/* * Name: Declan Simkins * Program: q2.c * Lab Section: Tuesday 2:00pm * Lab Instructor's Name: Stephanie Husby * CMPT 360 * Instructor's Name: Cam Macdonell * -------------------- * Desc: Lab 2 Question 2 * Opens a file, forks, then attempts to access the file descriptor * from both the parent a...
C
#include <stdio.h> #include <assert.h> #include <string.h> #define MAXLINES 5000 #define MAXLINESIZE 256 char **max(char **a, int len) { char **m; m = a; while(--len > 0) { a++; if(strcmp(*a, *m) > 0)//*a > *m) m = a; } return m; } void sort(char **a, int len) { char **tp; char *t;...
C
#include "xmempool.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #ifndef _WIN32 #include <unistd.h> #endif typedef struct xmem_pool_block { char* start; uint32_t block_size; struct xmem_pool_block* next; uint32_t is_block_start; } xmem_pool_block; typedef struct xmem_pool { uint32_t block_s...
C
#include "push_swap.h" void destroy_stack(t_stack **stk) { t_stack *tmp; while (*stk) { tmp = *stk; *stk = (*stk)->next; free(tmp); tmp = NULL; } } int stack_size(t_stack *stk) { int size; size = 0; while (stk) { size++; stk = stk->next; } return (size); } void ft_exit(void) { write(1, "Er...
C
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <pthread.h> #define _OPEN_THREADS #include <time.h> #include <errno.h> #include "linux_nfc_api.h" pthread_cond_t condition = PTHREAD_COND_INITIALIZER; pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER...
C
/** * Program to execute strcat ,strcpy and strcmp string functions. * * Compilation: gcc -o ques_14 ques_14.c * Execution:./ques_14 * * @Aniket , (1910990836) , 23/07/2021 * Assignment 1 */ #include<stdio.h> #include<string.h> #include<stdlib.h> #define N 100 /** * Function to find length of the string * ...
C
#include<stdio.h> #include "my-math.h" #define LEVEL 2 int main () { printf("We are going to multiply with integers from a header file.\n"); printf("The product of 4 and 5 is %d.\n", multiply(4 , 5)); printf("------- Macro Code---------\n"); printf("The square of 4 is %d\n", SQUARE(4)); #if LEVEL > 0 print...
C
#define MAX_BUFFER_SIZE 128 pthread_mutex_t mutex; pthread_cond_t cond; GMainLoop *loop = NULL; gboolean callback(GSocketService* service, GSocketConnection *conn, GObject* *object, gpointer user_data) { GError *error = NULL; int len; char buffer[MAX_BUFFER_SIZE] = {0x00, }; GInputStream *is = g_io_strea...
C
//Raymond Waidmann //rcw5k2 //e-hw3.c //DO NOT HARDCODE FILENAMES //DO NOT HARDCODE THE COUNT OF RECORDS IN THE INPUT FILE #include <stdio.h> #include <stdlib.h> int get_record_count(char*); int load_data(char*, int*, float*, int); void print_data(int*, float*, int); int highest_amount(float*, int); int lowest_amoun...
C
/*============================*/ /* Euler method for ODE (IVP) */ /* x' = f(t,x) /* x(T0)=X0 /*============================*/ #include <stdio.h> #include <math.h> /*--- Calculate from t=T0 to t=T1 ---*/ #define T0 0.0 #define T1 5.0 /*--- Initial data ---*/ #define X0 2.0 /*--- parameter(s) ---*/ #define...
C
#include <stdio.h> #include <stdlib.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ int main(int argc, char *argv[]) { int n, n1, n2, n3, i, sum=0; printf("ڿ Է :"); scanf("%d", &n); n1=n/100; n2=n%100/10; n3=n-(n1*100+n2*10); sum=n1+n2+n3; printf("%d\n",...
C
#include <stdio.h> int main(void) { int A[10]; int v,sum,i,j,m; printf("Ingrese 10 numeros enteros\n"); printf("\n"); for (i = 0; i < 10; ++i){ printf("Ingresa el valor [%i]: ",i ); scanf("%i",&v); A[i]=v; sum += A[i]; } printf("\n"); printf("El arr...
C
#ifndef __UTILITIES_H__ #define __UTILITIES_H__ /*************************** MACROS ****************************/ #define TEST(condition, func_name) ((1) == (condition))? \ printf("%s:\t\x1b[32m SUCCESS \x1b[0m | Line: %d\n", #func_name, __LINE__) : \ ...
C
#include <stdio.h> #define PI 3.1416 int y=2; int main(){ float radio ,L=0; printf("Digite el valor del radio: "); scanf("%f", &radio); L= y * PI * radio; printf("La longitud de la circunferencia es: %.2f", L); return 0; }
C
#include "binary_trees.h" /** * binary_tree_balance - calculates balance of a tree * @tree: pointer to the root * Return: integer */ int binary_tree_balance(const binary_tree_t *tree) { int height_r = 0, height_l = 0; if (tree == NULL) return (0); height_r = find_height(tree->right); height_l = find_height(...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_getopt_tools.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #define DLAN 50 int main() { char plik[DLAN]; char ch; FILE *wp; long licznik,koniec; puts("podaj nazwe pliku: "); gets(plik); if((wp=fopen(plik,"rb"))==NULL) { fprintf(stderr,"nie moge otworzyc pliku %s\n",plik); exit(1); } ...
C
/** * \file main.c * \author wzj * \brief * \version * \note * \date: 2015年10月29日 星期四 20时09分47秒 CST * * 找到最短路径, 使用最短路径算法时,额外保留当前路径上最高权值 * 的边,用于费用减免 */ #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXN (1024) #define INF (99999) int n_vetex; int map[MAXN][MAXN]; int max_e[MAXN][MAXN]...
C
#include "demo.h" struct sym_list Head; /* head of singly-linked list */ /* * Daemon provides an interactive associative memory * via a socket-based interface. Clients either set * values with an assignment statement or access * values with a $ preface. When the value is * accessed, we write it onto the client's...
C
/* Tina Tami * * This file contains the data structure described * in the stack.h file. */ #include <stdlib.h> #include <stdio.h> #include "stack.h" #define STACK_SIZE 100 /* These are the variables we will need. */ struct stack { int pushes; int pops; int maxSize; int currentSize; int myStack[STACK_SIZE]; ...