language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#pragma once /** * File for utility functions used by network code * authors: welch.da@husky.neu.edu, lanotte.m@husky.neu.edu */ /** * Creates a serializer object for an message. * @param kind Kind of message * @param sender Sender node. * @param target Target node. * @param id Message Id. * @return returns ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* coord_helpers.c :+: :+: :+: ...
C
#include "head.h" typedef struct msg_buf { long mtype; // тип сообщение char msg[MSGSZ]; // сообщение размером 128 байт } msg_s; msg_s recv; msg_s send; int msqid_r; int msqid_s; int msqid_r2; int main() { send.mtype=100; int msgflg = IPC_CREAT | 0666; // создание очер...
C
#include <queue.h> #include <assert.h> #include <stdio.h> /*Tester for creating a queue*/ void test_create(void) { queue_t q = queue_create(); printf("test starting: test_create\n"); assert(q != NULL); printf("test completed: test_create\n\n"); } /*Tester for enqueueing and dequeuing one data*/ void test_queue...
C
/* pconic --- plot Bezier curves */ /* Note: this program does not yet work properly with the HPGL * library. It was originally written for a non-HPGL plotter. */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <math.h> #include "hpgllib.h" #define NPTS (16) struct Weights { double w0; ...
C
#include "strs.h" void put_char(char c) { write(1, &c, 1); } int ft_strlen(char *str) { int size; size = 0; while (*str++) size++; return (size); } void ft_putstr(char *str) { int i; i = 0; while (str[i]) { put_char(str[i]); i++; } } char *ft_concat(char *str1, char c) { char *new_str; int i; ...
C
#include <stdio.h> int f(int x, int y) { if (x > 42) { y += 1; } else { y += 2; } return y; } int main() { int x, y; scanf("%d %d", &x, &y); printf("%d\n", f(x, y)); }
C
#include <stdio.h> //int main() //{ // printf("һ:>"); // long long int a = 0; // scanf("%lld", &a); // // a /= 1000; // int arr[4] = { 0 }; // printf("\n47:>"); // // for (int i = 0; i < 4; i++) // { // arr[i] = a % 10; // a /= 10; // printf("%d\t", arr[i]); // } // printf("\n"); // // return 0; //} int main() { ...
C
#include<stdio.h> #pragma warning(disable:4996) const int coverType[4][3][2] = { {{0,0}, {1,0},{0,1} }, {{0,0},{0,1},{1,1} }, {{0,0},{1,0},{1,1} }, {{0,0},{1,0},{1,-1} } }; int cover(); int set(int y, int x, int type, int toggle); int testcase; int h=0, w=0; int board[5][5] = { {0} }; int main(vo...
C
/* * ===================================================================================== * * Filename: test.c * * Description: * * Version: 1.0 * Created: 11/17/2019 15:41:50 * Revision: none * Compiler: gcc * * Author: Junha Hyung (), sharpeeee@kaist.ac....
C
#define BST_H struct bnode; typedef struct bnode* BNode; struct bnode{ BNode left; BNode right; void* e; int height; }; struct bst; typedef struct BST* BST; struct BST{ BNode root; int size; int (*compare)(void*,void*); }; BST createBST(int(*f)(void*,void*)); BST insertInBST(BST b, void...
C
#include <stdio.h> #include <string.h> #include "libft.h" #include "ft_printf.h" #include <stdint.h> #include <float.h> #include <math.h> #include <locale.h> #define FMT "%#x", 256 int main(void) { int len; char char1 = 'a'; char *str1 = "Larlyne"; int int1 = 5; int int2 = 2; double dbl = 0; uint64_t bigin...
C
#include "page_heap.h" #include <stdio.h> #include <unistd.h> #include <assert.h> #include "common.h" /* `page_heap->free_spans[i]` contains spans with `num_pages == i + 1`. * Except the last element `page_heap->free_spans[255]`, which contains spans * with `num_pages >= 256`. */ struct page_heap { struct list ...
C
/* programer :aiswarya aim :convert decimal into base(-2) time complexity : O(n) */ #include<stdio.h> #include<conio.h> #include<stdlib.h> int* func(int in){ int carry=0,iter=31,*base; base=(int *) malloc(sizeof(int)*(32)); while(in>0 || carry == 1){ //if carry and input both are 1 input =0 an...
C
#include <assert.h> #include <gl/drawable.h> static_assert(sizeof(uint32_t) == sizeof(GLfloat), "GLfloat must be 32 bits"); int gl_load_static_indexed_drawable(drawable *d, uint32_t *data, size_t n_vertices) { // drawing triangles assert(n_vertices % 3 == 0); d->size = n_vertices; glGenV...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <netdb.h> #include <netinet/in.h> #include <arpa/inet.h> #include <sys/socket.h> #include <sys/types.h> #include <signal.h> #include <unistd.h> #include <pthread.h> #define MAX 1048 #define NAME_LENGTH 30 #define PORT 4444 volatile sig_atomic_t signa...
C
/** * @file kernel_buffer.c * @author Eshan Shafeeq * @date 21/03/2016 * @version 0.1 * @brief A character device driver to implement the fops * structure, communication between user space and * kernel space, Dynamic allocation of major number * and registration of a characte...
C
// // OS Windows // 2020.01.20 // // [Algorithm Problem Solving] // // [] <BOJ #2857> FBI // #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #define SZ 13 #define T 5 char input[SZ]; int main(void) { freopen("input2857.txt", "r", stdin); register int tc, i, flag = 0; for (tc = 1; tc <= T; ++tc) { scanf("%s", &...
C
/* define boolean variable */ typedef char bool; /* false = 0, true = 1 */ enum { false, true }; /* define pair */ struct pair { int sent, back; }; /* * the function to make pair * @param int s, int b * @return struct pair (sent = s, back = b) */ struct pair makePair(int s, int b) { struct pair p; p.sent...
C
#include<stdio.h> int main(){ char str1[20],str2[20],ch; int i,j,freq1[26],freq2[26]; printf("\nEnter String 1 :"); scanf("%s",str1); printf("\nEnter String 2 :"); scanf("%s",str2); for(i=0;i<26;i++){ freq1[i]=freq2[i]=0; } for(i=0;str1[i]!='\0' && str2[i]!='\0';i++){ freq1[str1[i]-'a']++; freq2[str2[i]-...
C
#include <stdio.h> #include <windows.h> HANDLE hp=NULL; int ReturnHostFromUrl(char **, char *); int main() { char *ptr = NULL; hp = HeapCreate(0,0x1000,0x10000); ReturnHostFromUrl(&ptr,"http://www.ngssoftware.com/index.html"); printf("Host...
C
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <fcntl.h> #include <sys/wait.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <ctype.h> #include <readline/readline.h> #include <readline/history.h> #define MAX_INPUT 256 char name[64] = "myShell"; char*...
C
#ifndef _FORMAT_H_ #define _FORMAT_H_ #include <stdlib.h> #include <conio.h> #include <stdio.h> const char report_interval[] = " %4.1lf-%4.1lf sec %ss %ss/sec\n"; const char result_t_upload[] = "[T-Upload] %4.1lf-%4.1lf sec %ss %ss/sec\n"; const char result_t_download[] = "[T-Dwload] %4.1lf-%4.1lf s...
C
#include<sys/types.h> #include<sys/stat.h> #include<unistd.h> #include<stdlib.h> #include<stdio.h> #include<time.h> #include<string.h> int main(int argc,char *argv[]) { int i=0; i=atoi(argv[1]); time_t xyz; char* cts; int day,year; char month[20],weekday[20],timee[20]; while(i!=0) { xyz=time(NULL); cts=ctime(&xyz);...
C
#include<stdio.h> #include<conio.h> #include<stdlib.h> struct list{ int data; struct list*next; }*start=NULL; struct list* NewNode() { struct list* Node=NULL; Node=(struct list*)malloc(sizeof(struct list)); Node->data=NULL; Node->next=NULL; return Node; } void PrintList() { struct list* ptr=start; whi...
C
/* Exercise 5.5 _____ Write versions of the library functions strncpy, strncat, and strncmp, which operate on at most the first n characters of their argument strings. */ // Header Files. #include "stdio.h" #include "stdlib.h" #include "string.h" // Macros. #define MAXLEN 1000 // Global Variables. ...
C
// Dato un albero binario di ricerca con i nodi colorati di rosso (0) // o di nero (1) stabilire la dimensione del sottoalbero rosso più // grande. #include <stdio.h> #include <stdlib.h> #include <stdbool.h> //Node structure: struct node { int key; int dim; // dimensione sottoalbero rosso int col...
C
#include <stdio.h> #include <pthread.h> #include <unistd.h> #include <sys/syscall.h> #include <malloc.h> using namespace std; struct nod { int info; struct nod *next; }; class stak { struct nod *top; public: stak(); void push(int); int pop(); bool isEmpty(); voi...
C
#include"tabtools.h" #include<stdlib.h> float **alloctab(int dim1, int dim2) { float **ptr; ptr = malloc(dim1*sizeof(float *)); if (ptr != NULL) { int i, taille_ligne = dim2*sizeof(float); float *tmp = malloc(dim1*taille_ligne); if (tmp != NULL) { for (i=0; i<dim1; i++)...
C
/* ** EPITECH PROJECT, 2018 ** create_draw_destroy ** File description: ** creates_draw_destroy */ #include "includes/my_screensaver.h" sfRenderWindow *create_windows(sfRenderWindow *window) { sfVideoMode mode = {1920, 1080, 32}; window = sfRenderWindow_create(mode, "My ScreenSaver", sfClose | sfFullscre...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "project2.h" /* *************************************************************************** ALTERNATING BIT AND GO-BACK-N NETWORK EMULATOR: VERSION 1.1 J.F.Kurose This code should be used for Project 2, unidirectional or bidirectional data ...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #define Size 128 int Balance(const char* line) { //проверяем баланс скобок char* processed = line; int openBr = 0; int closeBr = 0; while (*processed != '\0') { if (*processed == '(') { openBr++; } else if (*processed == ')') { ...
C
#include <CL/cl.h> #include <stdio.h> #include<stdlib.h> #include<math.h> typedef float real_dt; #if 1 void dump_error(cl_int *err) { if(err[0]==CL_INVALID_PLATFORM) { printf("\nInvalid platform"); } else if (err[0]==CL_INVALID_DEVICE) { printf("\nInvalid Device"); } else if(err[0]==CL_INVALID_CONTEXT) { printf("...
C
#include <stdint.h> #include <stdlib.h> #include <stdio.h> #include "memory.h" mem* initMemory(Seq_T prog){ mem *newMem = malloc(sizeof(mem)); newMem->segments = Seq_new(0); newMem->unmapped = Seq_new(0); newMem->totSegs = 0; newMem->progCount = 0; //Push the program into newMem Seq_addhi(newMem->segments, p...
C
#ifndef ROUTINE #define ROUTINE /** * ( ...) **/ #include "sparseMatrixOperation.h" #include "error.h" #include "type.h" #include <stdlib.h> #include <float.h> #include <math.h> #include <stdio.h> int ReadPermutationFromFile(char* fileName, int** iperm, int n); /** * API * int parserSystem(int typeFile...
C
/* --PROGRAM NAME: knkcch03e06.c --PROGRAM STATEMENT: Show how to modify the addfrac.c program of Section 3.2 so that the user is allowed to enter fractions that contain spaces before and after each / character. */ #include<stdio.h> //------------------------START OF MAIN()-------------------------------------- int m...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* set_struct.c :+: :+: :+: ...
C
#include<stdio.h> #include<stdlib.h> int main() { int a; int *p; p = (int*)malloc(sizeof(int)); char *c; c = (char*)malloc(sizeof(char)); printf("%d\n",p); printf("%d",c); }
C
#include <stdio.h> #include <stdlib.h> #include <time.h> #include <CDataStructures.h> int main(int argc, char **argv) { printf("Testing SList.\n"); cds_slist_t *slist = cds_slist_new(); if (slist == NULL) { printf("Could not allocate memory for SList.\n"); } if (CDS_IS_ERROR(cds_slist_init...
C
#include <stdio.h> #include <math.h> int main() { int n, num; scanf("%d", &n); scanf("%d", &num); int arr[n]; int index=-1; for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); if(num==arr[i]) index=i; } int mindiff=0;int diff; if(index>-1) printf("...
C
/* * In The Name Of God * ======================================== * [] File Name : traxboard.c * * [] Creation Date : 26-04-2015 * * [] Created By : Parham Alvani (parham.alvani@gmail.com) * ======================================= */ /* * Copyright (c) 2015 Parham Alvani. */ #include <string.h> #include "tra...
C
#include "types.h" #include "stat.h" #include "user.h" int main(void) { int pid = fork() ; if(pid == 0) { setpriority(pid, 5); while(1) {sleep(10); printf(1, "CHLID\n"); } }else{ setpriority(pid, 10); while(1) {sleep(10); printf(1, "PARENT\n"); } } /*while(1){...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <sys/socket.h> #include <netinet/in.h> #include <time.h> void send_msg(int sock); void *recv_msg(void *arg); void error_handling(char *message); #define BUFSIZE 100 int myselect = 1; struct records { int hand; int score; }; ...
C
/* NIM : 13515028 Nama : Taufan Mahaputra Tanggal : 29 September 2016 Topik praktikum : ADT Stack Deskripsi : Implementasi ADT Stack */ #include <stdio.h> #include "stackt.h" void BacaString(char K[100]); int CharToInt(char K); void IsiStack(Stack *S, char K[100]); Stack JumlahStack(Stack s1, Stack s2);...
C
#include "L293DD.h" #include "Timer.h" unsigned char Stepper_Motor_Array[8] ={ 0x80, 0xA0, 0x20, 0x60, 0x40, 0x50, 0x10, 0x90 }; /* unsigned char Stepper_Motor_Array[8] ={ 0x80, // 1000 0xA0, // 1100 0x40, // 0100 0x60, // 0110 0x20, // 0010 0x30, ...
C
#include<stdio.h> struct pokemon{ int no; char name[20]; int hp; int atk; int def; }; int main(void){ struct pokemon nakama[4] = { {1, "ピカチュウ", 100, 67, 60}, {2, "ルギア", 250, 120, 101}, {3, "エルフーン", 89, 60, 50}, {4, "ホエルオー", 358, 123, 45} }; int in; printf("番...
C
#include <stdio.h> #include <stdlib.h> int main(){ float s[6] = {1.08988,2.982382389,3.982398289,4.0283823,4.92838238,5.0283802}; // FILE * stream = fopen("inputfile", "wb"); // fwrite(s, sizeof(float), 6, stream); float * ptr = (float *)malloc(6 * sizeof(float)) ; // fclose(stream); // stream = f...
C
#include <stdio.h> #include<stdlib.h> struct LowerTriangularMatrix { int *A; int n; }; void Set(struct LowerTriangularMatrix *m, int i, int j, int x) { if(i >= j) { m->A[i*(i-1)/2+j-1] = x; } } void Create(struct LowerTriangularMatrix *m){ int x, i=0, j=0; printf("Enter all the ele...
C
#include <stdio.h> void preenchevet(float x[],int y) { int i; for(i=0;i<y;i++){ printf("digite os valores: "); scanf("%f",&x[i]); } } float somavet(float x[],int y) { int i; float soma=0; for(i=0;i<y;i++){ soma=soma+x[i]; } return soma; } float mediavet(float x[],int y) { int i; float cont=0,soma=0,m...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_strsplit.c :+: :+: :+: ...
C
/* Операторы сравнения больше и меньше Оператор больше > берёт 2 числа и возвращает 1 если первое число больше второго или 0 иначе Оператор меньше < берёт 2 числа и возвращает 1 если первое число меньше второго или 0 иначе */ #include <stdio.h> int main() { printf("%i\n", 20 > 10); printf("%i\n"...
C
// ecrire une fct qui ret 1 si juste des char alpha ou 0 sinon #include <stdio.h> int ft_str_is_alpha(char *str); int ft_str_is_alpha(char *str) { int i; i = 0; while (str[i]) { if ((str[i] >= 65 && str[i] <= 90) || (str[i] >= 97 && str[i] <= 122)) { i++; } else return(0); } return (1); } in...
C
#include<stdio.h> void main() { int n,r,count=0; scanf ("%d",&n); while(n>0) { r=n%2; if(r==1) count++; n=n/2; } printf("%d",count); }
C
#include <stdio.h> struct tlines { int nline; struct tlines *next; }; struct tword_lines { char *word; int num; struct tlines *lines; struct tword_lines *lefttree; struct tword_lines *righttree; }; void printlines(struct tlines *lines); void printword_lines(struct tword_lines *p) { if (p != NULL) { printw...
C
void merge(int* A, int ALen, int m, int* B, int BLen, int n) { // write code here for(int i=m+n+1;i>=0;i--){ //B꣬Aе if(n-1<0||(m-1>=0&&(*(A+m-1)>*(B+n-1)))) { *(A+m+n-1)=*(A+m-1); m--; } else { *(A+m+n-1)=*(B+n-1); n...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* put_bonus.c :+: :+: :+: ...
C
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ /* * See COPYRIGHT in top-level directory. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <sys/time.h> // for gettimeofday() #include "abt.h" #define DEFAULT_NUM_XSTREAMS 4 #define DEFAULT_N...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> void memdump(char *string, int zeilen); void print_line(char *pos); int memreplace(char *copy, char cin, char cout, char **pInt); int main(int argc, char **argv) { if (argc != 5) { printf("Incorrect usage!"); return -1; } char *i...
C
#include "os.h" CPU_DATA OSPrioTbl[OS_PRIO_TBL_SIZE]; void OS_PrioInit( void ) { CPU_DATA i; for ( i=0u; i<OS_PRIO_TBL_SIZE; i++ ) { OSPrioTbl[i] = (CPU_DATA)0; } } void OS_PrioInsert (OS_PRIO prio) { CPU_DATA bit; CPU_DATA bit_nbr; OS_PRIO ix; ix = prio / 32; bit_nbr = (CPU_DATA...
C
#include "push_swap.h" t_op *solver_ent(t_ps *ps) { int len; len = get_stacklen(ps->a); if (len == 1) return (NULL); else if (len == 2) return (solve_two(ps)); else if (len == 3) return (solve_three(ps->a, ps)); else if (len == 4) return (solve_four(ps)); else if (len == 5) return (solve_five(ps)); ...
C
#include<stdio.h> int N; int A[10000][10000]; int Left, Right; void readCase() { int i,j; Left = 0; scanf("%d", &N); for (i = 0; i < N; i++) { for (j = 0; j < N; j++) { scanf("%d", &A[i][j]); if (i == j) { Left += A[i][j]; } } } } void solveCase() { int i,j; Right = 0; j = N - 1; for (i = 0...
C
#include<stdio.h> main() { FILE *fp; char ch; printf("output\n"); fp=fopen("shipu.txt","r"); if(fp==NULL) { printf("\n Error! No file found.\n"); } while((ch=getc(fp))!=EOF) { printf("%c",ch); } fclose(fp); }
C
#ifndef _LOGIC_H #define _LOGIC_H #include "connection.h" #define JOKER_BLACK_RANK 14 #define JOKER_RED_RANK 15 #define NUM_CARDS 54 #define NUM_PLAYERS 3 typedef enum { SPADE, HEART, CLUB, DIAMOND } Suit; typedef struct card_t { unsigned short rank; Suit suit; } Card, *PCard; typedef enum { SINGLE, PAIR,...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <readline/readline.h> #include "sc.h" #include "sc_parser.h" sc_val *sc_false; sc_val *sc_quote; sc_val *sc_true; sc_val *sc_null; sc_ex sc_exception; void sc_print(sc_val *val, int is_rest) { if (val->quoted) printf("'"); switch(val->type) ...
C
bool key_press(u32 k) { /* TODO(neet): Make it so you can assign a currently using keyboard so you don't have to pass the OsKeyboard to this function */ struct OsKeyboard *keyboard = &os_input.keyboards[0]; if(keyboard->keys[k] && !keyboard->down[k]) { return(1); } return(0); } bool key_release(u32 k) { ...
C
// Module stuff. #include <types.h> //#include <timers.h> #include <dlfcn.h> #include <dirent.h> #include <stdio.h> #include <string.h> #include <stdlib.h> typedef struct module { char name[255]; void* lib; int (*init)(int moduleno); int (*draw)(int argc, char* argv[]); int (*deinit)(); } module; static struct...
C
#include <stdlib.h> #include <stdio.h> #include <stdbool.h> #include <string.h> #include <ctype.h> #include <conio.h> #include <time.h> #include <windows.h> #include "book.h" #include "member.h" #include "admin.h" #include "menu.h" #include "dataTypes.h" #include "utilities.h" void searchBook() { ...
C
#include<stdio.h> // Prototypes int nextNum(int prevNum, int currNum); int main(void) { int userChoice = 0; int j = 0; printf("How many elements of the Fibonacci sequence would you like? "); scanf("%d", &userChoice); int fibArray[userChoice - 1]; fibArray[0] = 1; fibArray[1] = 1; for(j = 2; j < userChoice...
C
void writenum(char al, char ar, char bl, char br) { write(1, &al, 1); write(1, &ar, 1); write(1, " ", 1); write(1, &bl, 1); write(1, &br, 1); if (!(al == '9' && ar == '8' && bl == '9' && br == '9')) write(1, ", ", 2); } void checknum(char al, char ar, char bl, char br) { if (al == bl) { if (ar < br) wri...
C
/* * util.c * * Created on: 2011/11/14 * Author: orz */ #include <stdio.h> #include "uniutil.h" #include "../mydef.h" #include "unitable.h" #include "../nicodef.h" int isMatchKanji(Uint16* u,Uint16* kanji){ if(kanji==NULL) return FALSE; while(*kanji!='\0'){ if(*kanji<=*u && *u<=*(kanji...
C
/* Solves http://projecteuler.net/problem=10 */ #include <stdio.h> #include <stdlib.h> #include "../includes/C/Seive.h" int main() { /* We start off with a sum of 2 because 2 is a prime and we only check odd numbers. */ double sum = 2; int number; char *table = (char*) malloc(sizeof(char) * 2000000); SeiveE(t...
C
#ifndef _KOWHAI_UTILS_H_ #define _KOWHAI_UTILS_H_ #include "kowhai.h" /** * @brief called when a difference is found between two tree's * @param param, application specific parameter passed through * @param left_node, points to the left node where the difference was found, or NULL if right node is unique * @para...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* draw.c :+: :+: :+: ...
C
#include "stdlib.h" #include "config.h" #include "uart.h" #include "adc.h" #include "interrupt.h" #include "gpio.h" #include "led.h" //A0: pulse output //A1: MQ out //A2: Hout //A3: Tout #define USEC_TO_SEC 1000000 #define CONV_FACTOR 0.00244140625 #define PULSE_THRESHOLD 70 // threshold value for pulse #...
C
// // MessageQueue.c // Assignment3 // // Created by Admin on 5/18/16. // Copyright © 2016 Admin. All rights reserved. // #include "MessageQueue.h" #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <assert.h> #include <stdio.h> #include <pthread.h> #include <string.h> #include <assert.h> #include ...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <string.h> #include <time.h> #include "pimagens.h" byte** fundo; void liberarMatriz2D(byte** p, int y) { int i; for(i=0; i<y; i++) { free(p[i]); } free(p); } float modulo(float x) { if(x<0) ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <termios.h> #include <errno.h> #define I2C_SLAVE 0x0703 #define I2C_TENBIT 0x0704 #define I2C_ADDR 0xA0 #define DATA_LEN 8 #define...
C
#include "typechecker.h" #include "evaluator.h" #include "generator.h" #include "parser.h" #include "misc.h" #include "table-stack.h" #include "error.h" #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> extern int yynerrs; extern void * kindex; //static const int ERROR_MSG_BUFFER=256; ext...
C
int main () { char s[50],w[50]; int l1,l2,i,j,a; scanf("%s %s",s,w); l1=strlen(s); l2=strlen(w); for (j=0;j<(l2-l1+1);j++) { a=0; if(w[j]==s[0]) { for (i=1;i<l1;i++) { if (w[j+i] == s[i]) a=1; else a=0; } if (a==1) { printf("%d\n",j); break...
C
#include <stdlib.h> #include <stdio.h> #include <netinet/in.h> #include <sys/socket.h> #include <unistd.h> #include <string.h> #include <inttypes.h> #include <time.h> typedef struct { uint16_t xid; /* Randomly chosen identifier */ uint16_t flags; /* Bit-mask to indicate request/response */ uint16_t qdcou...
C
/* * TEST SUITE FOR MB/WC FUNCTIONS IN CLIBRARY * * FILE: dat_strxfrm.c * * STRXFRM: size_t strxfrm (char *s1, const char s2, size_t n); */ /* * NOTE: * * Return value and errno value are checked only for 2nd string: * org2[]; n1 and n2 don't mean bytes to be translated. * It means a ...
C
#include<sys/socket.h> #include<netinet/in.h> #include<arpa/inet.h> #include<stdio.h> #include<stdlib.h> #include<unistd.h> #include<errno.h> #include<string.h> #include<pthread.h> #include<sys/types.h> #include<signal.h> #define MAX_CLIENTS 100 #define BUFFER_SZ 2048 #define NAME_LEN 32 static _Atomic unsigned int c...
C
#include <stdio.h> #include <stdarg.h> #include <stdlib.h> #include <errno.h> #include <stdint.h> #include <unistd.h> #include <fcntl.h> #include <inttypes.h> #include "spi-driver.h" #include "cfaf128128b-0145t.h" #include "boris-image.h" #define pabort(s) {perror(s); abort();} typedef struct _6bit { int val:6;} uint...
C
#include <malloc.h> #include <stdlib.h> #include <string.h> #include <stdio.h> typedef int boolean; #define true 1 #define false 0 typedef void (*Func)(); typedef struct _St_A { Func *vt; } _class_A; _class_A *new_A(void); void _A_m1( _class_A *this, int _n ) { printf("%d %d ", 1, _n); } void _A...
C
/* ** EPITECH PROJECT, 2020 ** NWP_myftp_2019 ** File description: ** clients_management */ #include "myftp.h" static bool add_new_client(int server_fd, fd_set *active_fd_set, global_t *glob) { struct sockaddr_in client_sock; size_t size; int new_client_fd; size = sizeof(client_sock); new_cli...
C
#include "measure_bar_mesh.h" #include <stdlib.h> #include "track.h" void load_measure_bars(MeasureBarMesh *mesh) { int beat_index = 0; float measure_position = 0; int measure_subbeat = 0; for (int i = 0; i < mesh->chart->num_measures; i++) { // set the current measures position ...
C
// //! \file txt_bm.c //! Bitmap text demo (modes 3,4,5) //! \date 20051009 - 20060930 //! \author cearn // // === NOTES === // * The current mode is indicated by the readable "mode 3", // "mode 4" or "mode 5". The cursor position is displayed in white. // * D-pad: moves cursor. // * L,R: switches between modes // ...
C
#include<stdio.h> int main() { int user1; int user2; printf("type two integer:\n"); scanf("%d %d", &user1, &user2); printf("you typed %d an %d\n. The sum of the two is %d\n.", user1, user2, user1 + user2); printf("you typed %d an %d\n. The product of the two is %d\n.", user1, user2, user1 * us...
C
#include<stdio.h> void replacetab(char s[]) { FILE*fp=fopen(s,"r"); FILE*fp1=fopen("out.txt","w"); char ch,str[100]={" "}; int iter=0; while((ch=fgetc(fp))!=EOF) { if(ch==' ') { str[iter++]='\\'; str[iter]='t'; } else{ str[iter]=ch; } iter++; } printf("%s",str); iter=0; while(str[...
C
/* Using LPT port to program AVR. Using SPI serial programing mode. * * Connection: * * LPT AVR * Bit0 MOSI * Bit1 SCK * Bit2 CS * _BUSY MISO * */ #include <sys/io.h> #include <stdio.h> #include <unistd.h> #include <assert.h> #...
C
#include <stdio.h> #include <stdlib.h> #include <omp.h> #include <math.h> int main(int argc, char **argv) { int N, i, j, k; double desvio, grandeMedia, *media, **matriz; printf("Enter with the number of individuals: "); scanf("%d", &N); media = (double *) malloc(N * sizeof(double)); printf("...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* viewer_draw.c :+: :+: :+: ...
C
#include "forces.h" #include "test_util.h" #include <assert.h> #include <math.h> #include <stdlib.h> const double G = 6.67408e-11; const double DT = 1e-12; const int STEPS = 100; double distance_vec(Vector v1, Vector v2){ Vector vec_diff = vec_subtract(v1, v2); return sqrt(vec_dot(vec_diff, vec_diff)); } double ...
C
/* Write a program which creates two processess. Process 1 count number of capital characters from demo.txt file. And process 2 count number of capital characters from hello.txt file. Both the processess writes its count in count.txt file. */ #include<stdio.h> #include<unistd.h> #include<fcntl.h> #include<sys/wait.h> ...
C
/* * ISets are set of some domain. Operations: * create, destroy, insert, member, size, and print */ #ifndef _EMERALD_ISET_H #define _EMERALD_ISET_H /* * Before using this, one must define the following: * ISetDomainType - a typedef for the domain * ISetHASH - a macro that computes an integer from a given * ...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> void printvector(int *a, int l){ printf("[ "); for(int i=0; i<l; i++){ printf("%d ", *(a+i)); } printf(" ]\n"); } /* Insertion sort algorithm scans the array and, for each element (except first one) loops back down to the beginning until it fi...
C
#include <stdbool.h> //for bool #include "eslink.h" #include "bootisp_host.h" #include "bootisp_target_config.h" #include "uart.h" #define ERR_BOOTISP_OK 0 #define ERR_BOOTISP_FAIL 1 static void bootisp_delayus(uint32_t n) { es_delay_us(n); } //异或校验 static uint8_t check_xor(uint8_t *data, uint8_...
C
#include <stdio.h> #ifndef __cplusplus typedef char bool; // define a type / create an alias/ compiler know the data type bool, can be used as parameter, #define true 1 // define a macro / compiler dont know true, but same as 1, so 1 and true can used interchangebly. #define false 0 #endif int mai...
C
//Cracks passwords. //Created on Sun November 14 2019. //@author: Omama Elrefaei. #include <cs50.h> //CS50 Library for C created by: Glenn Holloway <holloway@eecs.harvard.edu>, David J. Malan <malan@harvard.edu>. #include <stdio.h> #include <crypt.h> // Used for crypt() function #include <string.h> #include <time....
C
/* smash.c main file. This file contains the main function of smash *******************************************************************/ #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <signal.h> //********************************************************************************...