language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/* Testing C types (char, numbers, addresses). */ #include <stdio.h> int test_types() { long x; double y; short z; char a; char* b; } void test_division() { /* Integer arithmic is truncated to zero. */ int z = 5 / 9; float y = 5.0 / 9.0; printf("%d \t %f \n", z, ...
C
// For better backtrace implementation #define __USE_GNU #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <signal.h> #include <execinfo.h> #define BUF_SIZE 1000 #define TRACEDEPTH 16 void builtin_gcc_trace( void){ printf("Builtin gcc return addresses:\n"); printf("Frame 0: PC=%p\n", __bui...
C
/* Program: Fill and display personal data Example of bitfield Compile: gcc main.c -o personal_data ------------------------------------- Run: ./personal_data */ #include <stdio.h> #include <string.h> typedef struct { unsigned is_male : 1; unsigned age : 7; u...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* h_cast.c :+: :+: :+: ...
C
/*We assume that we have a polynomial with 5 arguments (N variable) The coefficients of this polynomial are in T array {1,-2,2,3,-5}. So the polynomial is T = x^4-2x^3+2x^2+3x-5. The program prompts the user to give a value to variable x (e.g. r=7) to compute the division between T and x-r. Prints the coefficients of t...
C
#include "signals.h" /** * current_handler_signal - check the current handler * Return: NULL or the pointer the current handler */ void (*current_handler_signal(void))(int) { void (*handler)(int); handler = signal(SIGINT, NULL); signal(SIGINT, handler); return (handler); }
C
#include "dominion.h" #include "dominion_helpers.h" #include <string.h> #include <stdlib.h> #include <stdio.h> #include <assert.h> #include "rngs.h" #define TEST_ALERT 0 void testDiscard() { struct gameState* G = malloc(sizeof(struct gameState)); int k[10] = {adventurer, council_room, feast, gardens, mine, remode...
C
/*** Author : Group 17 * Rahul Varshneya * Anvit Singh Tawar * Shivam Agarwal * Alankar Saxena Date Sun 08 April 2012 02:42:38 PM IST gait.c : File contains various walking and turning motion functions for the hexapod Please include gait.h file to call function from this file */ /*****************************...
C
#include<stdio.h> #include<fcntl.h> #include<dirent.h> #include<stdlib.h> #include<string.h> int main(int argc, char *argv[]){ if(argc != 2){ printf("Invalid number of arguments\n"); printf("Usage: PROG_NAME FILE_NAME\n"); exit(1); } char *filename = argv[1]; creat(filename,0777); int fd = open(filename, ...
C
#include <stdio.h> #include <time.h> void selectionSort(int v[], int n) { int i, j, min, temp; for(i = 0; i < n - 1; i++) { min = i; for(j = i + 1; j < n; j++) if(v[j] < v[min]) min = j; temp = v[i]; v[i] = v[min]; v[min] = temp; }...
C
/* * * FileName : webserver.c * Description : This file contains SW implementation of a HTTP-based webserver that accepts multiple * simultaneous connections * File Author Name: Bhallaji Venkatesan * Tools used : gcc, Sublime Text, Webbrowse...
C
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /* * File: main.c * Author: Nado * * Created on 7. Mai 2017, 16:16 */ #include <stdio.h> #include <stdlib.h> #...
C
// // exercise7_9.c // C-Exercise // // Created by 许浩 on 2020/7/16. // Copyright © 2020 许浩. All rights reserved. // #include "exercise7_9.h" // 使用continue跳过部分循环 int exercise7_9(void){ const float MIN = 0.0f; const float MAX = 100.0f; float score; float total = 0.0f; int n = 0; float min = ...
C
#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <err.h> /* Напишете програма на С, която да работи като обвивка на командата sort тоест вашата програма изпълнява sort като всички подадени параметри се предават на sort. Изхода за грешки по време на изпълнението да отива във ...
C
#include<stdio.h> #include<stdlib.h> #include<time.h> clock_t start,stop; double duration; void PrintN(int N) { if(N){ PrintN(N-1); printf("%d\n",N); } return; } void PrintN(int N); int main() { int N; scanf("%d",&N); start=clock(); PrintN(N); stop=clock(); duration=((double)(stop-start))/CLK_TCK; printf("%e\n",d...
C
/* * Copyright (c) 2006 Jakub Jermar * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * - Redistributions of source code must retain the above copyright * notice, this list of condit...
C
#ifndef SOUND_PLAYER_H #define SOUND_PLAYER_H #include "sound_generator.h" #include "ex2.h" #include "efm32gg.h" /* Waveform to use when playing sound. */ typedef enum SoundType { Saw, Triangle, Square } soundType_t; /* State storing if music should be played or not. */ typedef enum PlayState { Running, Done, Paus...
C
#include <stdio.h> #include <stdlib.h> int sommeTableau(int tableau[], int tailleTableau); double moyenneTableau(int tableau[], int tailleTableau); void copie(int tableauOriginal[], int tableauCopie[], int tailleTableau); void maximumTableau(int tableau[], int tailleTableau, int valeurMax); void ordonnerTableau...
C
#include <gtest/gtest.h> #include <kmeans/geometry/point.h> TEST(Point, CalculateDistanceSamePoint) { struct KM_Point *point1 = KM_Point_Create(2, NULL); struct KM_Point *point2 = KM_Point_Create(2, NULL); point1->coord[0] = 2; point1->coord[1] = 2; point2->coord[0] = 2; point2->coord[1] = 2; ...
C
//Wildcard(通配符) Matching /* '?' Matches any single character. '*' Matches any sequence of characters (including the empty sequence). The matching should cover the entire input string (not partial). The function prototype should be: bool isMatch(const char *s, const char *p) Some examples: isMatch("aa","a") → false...
C
// Implements a dictionary's functionality using a Hash function // Cheyanna Graham // Aug 2019 #include <ctype.h> #include <stdbool.h> #include <stdio.h> #include <string.h> #include <stdlib.h> #include "dictionary.h" // Represents number of buckets in a hash table #define N 26 // Represents a node in a hash table...
C
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int main() { int A, B, C; scanf("%d", &A); scanf("%d", &B); scanf("%d", &C); if((A==C)||(A==B)||(C==B)) { printf("S"); } else if (((A+B)==C)||((B+C)==A) || ((C+A)==B)) { printf("S"); } else { printf("N"); ...
C
#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<stdlib.h> #include<string.h> // ɾַָĸ char* deleteCharacters(char * str, char * charSet) { int hash[256]; if (NULL == charSet) return str; for (int i = 0; i < 256; i++) hash[i] = 0; for (int i = 0; i < strlen(charSet); i++) hash[charSet[i]] = 1; in...
C
#include "uls.h" void mx_printerr(t_errors errors, char s) { if(errors == INVALID_ARGV) { mx_print_error("uls: illegal option -- -"); mx_print_error("\n"); mx_print_error("usage: uls [-ACSTafhilorstu1] [file ...]"); } else if(errors == INVALID_FLAGS) { mx_print_error("uls: i...
C
#include <stdio.h> int Fibonacci(int n,int a, int b) { if(n<=2) { printf("%d\n", b); return 1; } else return Fibonacci(n-1, b, a+b); } int main(void) { int n, x; scanf("%d", &n); for(int i=0; i<n; ++i) { scanf("%d", &x); Fibonacc...
C
/*Reading Map*/ #include<stdio.h> #include<string.h> int main() { FILE *ptr_file; char cfile; /*indexing variable*/ int i = 0;/*keyword_string*/ int j = 0, k = 0;/*ns_list or ew_list*/ int m = 0; /*at_and_string*/ int r = 0, s = 0;/*landmark entrance*/ int u = 0, v = 0;/*landmark boundary*/ /*enable variabl...
C
#include <stdio.h> #include <locale.h> //быстрая сортировка void qsort(int* arraySize, int start, int finish){ int i=start, j=finish, x=arraySize[(start+finish)/2]; do { while (arraySize[i]<x) i++; while (arraySize[j]<x) j--; if(i<=j){ if(arraySize[i]>arraySize[j]){ int tmp = arraySize[i]; arrayS...
C
/* * memdebug.h * * 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; either version 2, or (at your option) * any later version. * * This program is distributed in the hope that it will be u...
C
#include "brainfuck.h" static struct globals* glob_accessor(struct globals* value) { static struct globals* glob = NULL; if (!glob && value) glob = value; return glob; } static struct globals* glob_init() { struct globals* glob = malloc(sizeof(struct globals)); if (!glob) err(1, "glob initia...
C
#include<stdio.h> #include<stdlib.h> struct node { int data; struct node *next; }*newnode,*temp,*head=NULL; void insertfirst(); void insertmid(); void insertlast(); void display(); int length(); void deletefirst(); void deletemid(); void deletelast(); int main() { printf("\t\t\t\t\t...
C
#include "include/Ncurses.h" #include "include/GameObject.h" #include "include/defs.h" #include "include/Matrix22.h" #include "include/Quaternion.h" #include "include/Time.h" #include <math.h> #include "include/Texture.h" #include "include/Panel.h" /** * renders a single fragment to the screen applying all shader fun...
C
#include<stdio.h> #include<stdlib.h> #include<string.h> int main() { char num1[50],num2[50]; int n1,n2; scanf(" %d",&n1); scanf(" %d",&n2); sprintf(num1,"%d",n1); sprintf(num2,"%d",n2); if(strlen(num1)!=strlen(num2)){ printf("nao e permutacao"); return 0; } for(in...
C
#include <list_link.h> inline void list_init(struct list_link* sent) { sent->prev = sent; sent->next = sent; } inline bool list_empty(struct list_link* sent) { if (sent->prev == sent) { dbg_assert(sent->next == sent); return true; } dbg_assert(sent->next != sent); return false; } inline void list_link(str...
C
#include "functions.h" int fibonacci(int n){ if(n==0) return 0; if(n==1) return 1; int current = 1, previous=0, temp; while(n>=2) { temp= current; current =current + previous; previous =temp; n--; } return current; }
C
#include "grafo.h" #include <stdio.h> #include <stdlib.h> #include "fila.h" #include "lista.h" struct grafo_ { int vertices; int arestas; LISTA* *listas_de_adjascencia; }; GRAFO* grafo_criar(int n) // Cria um grafo com n vértices { GRAFO* g = (GRAFO*) malloc(sizeof(GRAFO)); if(n >= 0 && g != NUL...
C
#include "holberton.h" #include <stdio.h> #include <stdarg.h> #include <stdlib.h> /** * get_int - convert integer to string * @list: the character to add to string * @char_count: number of character that stores in buffer. * Return: string */ char *get_int(va_list list, int *char_count) { int num, num_tmp, len = ...
C
#include <stdio.h> #include <unistd.h> #include <stdlib.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <dirent.h> #include <sys/wait.h> void func(int signo) { //printf("I'm here\n"); ; } void readDirectoryRecursive(char* directoryPath, int indent){ // opens a directory. Returns ...
C
#include <stdio.h> #include <stdlib.h> int main(void) { //Описание указателя на целое число int *x; int n,i; printf("Введите размерность массива: "); scanf("%d",&n); //выделение памяти x = (int*)malloc(sizeof(int)*n); for(i=0; i<n; i++) { //вычисление значения элементов массива ...
C
#include <libmybox.h> sqlite *db_connect(const char *database) { char *errmsg=NULL; sqlite *db_id=NULL; db_id=sqlite_open(database, 0, &errmsg); if(!db_id) { printf("%s\n",errmsg); free(errmsg); return 0; } return db_id; } void db_clean_buffer(void) { memset(SQL_R...
C
/* 实验8_2 题目: 编写程序,建立一个学生基本信息结构,包括学号、姓名以及语文、数学、英语 3门课程的成绩, 输入 n 个学生的基本信息,写到文本文件 student.txt 中。 再从文件中取出数据,计算每个学生3门课程的总分和平均分(保留2位小数),并将结果输出至屏幕上。 构成: writeData函数功能:打开文件,将输入的基本信息fprintf到文件student.txt(FILENAME)中,关闭文件 calData函数功能:打开文件FILENAME,用结构指针每次读一个结构并计算所需数值输到显示器上,直到structpoint到达文件的末尾(NULL/EOF需执行时再看) 输出结束,关...
C
// //^ӦĶʱΪ1ͬʱΪ0 /*#define _CRT_SECURE_NO_WARNINGS #include<stdio.h> #include<stdlib.h> int main(){ int a, b; unsigned result; printf("please input a:"); scanf("%d", &a); printf("plaese input b:"); scanf("%d", &b); printf("a=%d,b=%d", a, b); result = a^b; printf("\na^b=%u\n", result); system("pause"); return...
C
#include <stdio.h> //1≤N≤10^15 int gcd(int n, int m) { if(n==0)return m; else return gcd(m%n,n); } int fsqrt(int n) { int s; int left=0; int right=n; while(left<=right) { int middle= (left+right)/2; if(middle*middle>n) { right = middle-1; } else { left = middle +1; s= ...
C
#include <stdio.h> int main(int argc, char const *argv[]){ int lado1, lado2, perimetro, area; scanf("%d\n %d", &lado1, &lado2); perimetro = 2 * (lado1+lado2); area = lado1 * lado2; printf("%d\n%d\n", area, perimetro); return 0; }
C
#include <stdio.h> #include <conio.h> #include <ctype.h> int main () { char str[150]; int i; printf ("Digite a frase desejada.\n"); fgets (str, 150, stdin); for (i = 0; str[i]!='\0'; i++) { if (isalpha(str[i])) { str[i]= tolower(str[i]); } } printf ("A frase, escrita em letras minusculas fica: %s.\n",...
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 numero =0; int i; char mayores=0; char menores=0; for(i=0;i<10;i++){ //printf("%d",i); printf("Ingrese un numero \n"); scanf(...
C
/* ========================================================================= * * HeapSort * Implémentation ode l'algorithme HeapSort. * ========================================================================= */ #include <stddef.h> #include <stdlib.h> #include "Sort.h" /* -----------------------------------------...
C
#include "avl.h" #include "testForTask.h" #include <stdio.h> #include <locale.h> #define WRONG_OPTION -1 int main(void) { setlocale(LC_ALL, "rus"); if (!tests()) { printf("Тесты провалены!\n"); return 1; } printf("Тесты пройдены успешно\n"); printf("Набор команд:\n"); printf("0 - Выход\n"); printf("1 - д...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_stack_emplace.c :+: :+: :+: ...
C
/************************************************************************* > File Name: bsearch.c > Author: jinshaohui > Mail: jinshaohui789@163.com > Time: 18-10-21 > Desc: ************************************************************************/ #include<stdio.h> #include<stdlib.h> #include<assert.h>...
C
#include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> int cmp(const void *a, const void *b) { return *(double *)a > *(double *)b ? 1 : -1; } int main() { double s, l, h; double x[4], y[4]; double x1, y1, x2, x3, x4, y2, y3, y4; while (~scanf("%lf%lf%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> void *service; char *auth; int main() { char s[32]; int i; unsigned int dl; // uint8_t unsigned int al; // uint8_t while (1) { s[0] = 0; printf("%p, %p \n", auth, service); fgets(s , 128, stdin); if (s[0] == 0) { s[0] = 0; return (0);...
C
#include <stdio.h> void strRot13(char str[]) { const int shift = 13; for ( int i = 0, ch = str[i]; ch != '\0'; i++, ch = str[i] ) { if ( ch >= 'a' && ch <= 'm' ) { str[i] = ch + shift; } else if ( ch > 'm' && ch <= 'z' ) { str[i] = ch - shift; } else if ( ch...
C
#include <stdio.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <omp.h> void swap(int64_t *ptr1, int64_t *ptr2 ){ int64_t temp; temp = *ptr1; *ptr1 = *ptr2; *ptr2 = temp; } int64_t choosePivot(int64_t *a, int64_t lo, int64_t hi){ return ((lo+hi)/2); } i...
C
// Program 5 - komunikacja przez netlink //send #include <sys/socket.h> #include <linux/netlink.h> #include <stdio.h> #include <malloc.h> #include <stdio.h> #include <string.h> #include <unistd.h> #define NLINK_MSG_LEN 1024 #define NETLINK_USER 31 int main() { int result; char* received="Hello"; int fd; struct ...
C
#include<stdio.h> #include<string.h> int main(void) { int t; char s[1000],p[1000]; scanf("%d",&t); while(t!=0) { scanf("%s",s); p=strrev(s); if(s==p) { printf("YES\n"); } else { printf("NO\n"); } t--; ...
C
/********************************************************** * Author : huang * Creat modified : 2020-07-20 21:29 * Last modified : 2020-07-20 21:29 * Filename : 20_字符数组.c * Description : * *******************************************************/ #include <stdio.h> int main() { //1. C语言没有字符串类...
C
#include <stdio.h> int main() { int pinakas[1000], i, c, max, sum; i = 0; while ((c = getchar()) != EOF) { pinakas[i] = c - '0'; i++; } max = pinakas[0] * pinakas[1] * pinakas[2] * pinakas[3] * pinakas[4]; for (i=1; i<=995; i++){ sum = pina...
C
#ifndef COMMON_RESIZABLE_BUFFER_H #define COMMON_RESIZABLE_BUFFER_H #define ERROR -1 #define EXTRA_SPACE 30 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stdbool.h> typedef struct resizable_buffer{ int size; char *buffer; }resizable_buffer_t; int resizable_buffer_create(resizable_buffer_t ...
C
#include <stdio.h> #include <stdio.h> #define mod 1000000007 int size = 0; void swap(int *a, int *b) { int temp = *b; *b = *a; *a = temp; } void heapify(int array[], int size, int i) { if(size>1) { int largest = i; int l = 2 * i + 1; int r = 2 * i + 2; if (l < size && array[l] > array[largest]...
C
#include <screen.h> #include <stdio.h> #include <stdlib.h> #include <timer.h> #define BUFFER_SIZE 10 * 1024 int main(void) { int err; printf("available resolutions\n"); int resolutions; err = screen_get_supported_resolutions(&resolutions); if (err < 0) return -1; for (int idx = 0; idx < resolutions; idx+...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "functions.h" int main(int argc, char** argv) { FILE* fp; fp = fopen("votes.txt","r"); char** nameArray = malloc(10 * sizeof(char *)); //Allocate row pointers int i; for(i =0; i< 10; i++) { nameArray[i] = malloc(25 * sizeof(char)); ...
C
/*swapping without using 3 variable*/ main() { int a,b; printf("Enter two Numbers: "); scanf("%d %d",&a,&b); b=b-a; a=a+b; b=a-b; printf("\nSwapped No. are a=%d & b=%d",a,b);}
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* substr.c :+: :+: :+: ...
C
#include <unistd.h> #include <stdlib.h> #include <stdio.h> #include <ctype.h> #include <errno.h> #include <time.h> #include <fcntl.h> #include <strings.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include "utilities.h" #includ...
C
/* Oskar Sobczyk - Problem palaczy tytoniu nr indeksu 281822 18.01.2017 */ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <pthread.h> #include <sys/types.h> #include <sys/time.h> #include <sys/stat.h> #include <fcntl.h> #include <semaphore.h> #include <unistd.h> #include <time.h> int main(int ar...
C
#include "cblas.h" #include "string.h" #include "stdio.h" #include "stdlib.h" #include "math.h" #define MAX(x, y) (x >= y ? x : y) void bias_add(float* in_layer, float* biases, float* result, int shape_b, int shape_h, int shape_w, int shape_d) { cblas_scopy( shape_b * shape_h * shape_w * shape_d, ...
C
// 7-SEG //0000-FFFF include "lpc214x.h" #include "stdint.h" #define IO1 0x10000 #define IO2 0x20000 #define IO3 0x40000 #define IO4 0x80000 #define IOX 0xF0000 #define IOXcl 0xFFFFF int count=0000; unsignedint d1,d2,d3,d4; unsigned char seg[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x67,0x77,0x7c,...
C
#include <arpa/inet.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <sys/socket.h> #include <sys/types.h> #include <unistd.h> #define SERV_PORT 8888 #define CLIE_PORT 9000 // 广播时客户端端口号需要确定值 #define BROADCAST_IP "172.23.63.255" // ifconfig查看广播地址 int main(int argc, char c...
C
#include "zap_tmp.h" int compare(const void* a, const void* b) { if ((*(utmp_t**)a)->ut_time > (*(utmp_t**)b)->ut_time) return 1; else if ((*(utmp_t**)a)->ut_time < (*(utmp_t**)b)->ut_time) return -1; else return 0; } void append_utmp_array(utmp_t* element) { utmp_array[utmp_idx] = (utmp_t*)malloc(UTM...
C
#include<stdio.h> int main(){ int bubble_num,i ; void sortDisplay(int bubble_set[],int length); printf(":"); scanf("%d",&bubble_num); printf("\n"); int bubble_set[bubble_num]; int length = sizeof(bubble_set)/sizeof(bubble_set[0]); for(i=0;i<=(length-2)/2;i++){ bubble_set[2*i]=2; ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define VERB_PTR 0x6473 #define NOUN_PTR 0x65A9 #define OBJLOC_PTR 0x62f5 #define VERB_NUM 56 #define NOUN_NUM 48 #define VERB_OFFL 0x6400 #define VERB_OFFH 0x6438 typedef struct { char verb[64]; int address; } verb_struct; typedef struct { char no...
C
// // Created by shuttle3468 on 8/2/17. // #include "origin.h" //! **Upper Hull and Lower Hull Algorithm** /*! 1. In case of upper hull formation we move from last element to the first and vice versa for lower hull.\n * * 2. Now we remove those points that are either **anti-clockwise or collinear** because being an...
C
#include <string.h> #include "memfile.h" #include "util.h" extern const char system_lsp[]; int _stdin_ungetch=0; FILE memp[1]; #if 0 struct __sFILE { unsigned char *_p; /* current position in (some) buffer */ int _r; /* read space left for getc() */ int _w; /* write space left for putc() */ s...
C
//Classe: Equipe #include "gerenciaEquipes.h" #include "structs.h" #include "validacoes.h" /* Mtodos */ //Objetivo : Exibir o menu CRUD da classe equipe. //Parmetros: //Retorno : *** void menuEquipeCRUD(char *opcaoUsuario, int *validaInteracao, int *qtdEquipes){ FILE *arqvEquipes; tEquipe tempStruct; ar...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> int strongPasswordChecker(char* s) { int longitud = strlen(s); int contain_min =0; int contain_may =0; int contain_num =0; if(longitud<=20 && longitud>=6){ for(int i=0;i<longitud;i++){ if((int)(s[i])>=48 && (int)(s[i])<=57 ){ ...
C
// // signal.c // TCP&C-Demo // // Created by sheng wang on 2019/10/22. // Copyright © 2019 feisu. All rights reserved. // #include "unp.h" void read_childpro(int sig) { int status; pid_t id = waitpid(-1, &status, WNOHANG); if (WIFEXITED(status)) { printf("remove proc id:%d \n", id); ...
C
#include<stdio.h> #include<conio.h> void main() { longint sum=0,i,n; clrscr(); printf("enter the n numbers"); scanf("%ld",&n); for(i=1;i<=n;i++) { sum=n*i; printf("\n 5*%ld=%ld"); } getch(); }
C
#include "stdio.h" #include "stdlib.h" #include "unistd.h" int main(){ pid_t pid=getpid(); pid_t sid = getsid(pid); char data[10]; //Write to /proc/*pid of the program*/fd/0. The fd subdirectory contains the descriptors of all the opened files and file descriptor 0 is the standard input (1 is stdout and 2 is stder...
C
/* ** EPITECH PROJECT, 2019 ** corewar ** File description: ** check_label_two */ #include "asm.h" int is_it_good(label_t *index, char *str) { int compt = 0; while (index != NULL) { if (my_strcmp(index->name, str) == 0) compt = compt + 1; if (compt == 2) return (84); ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "queue.h" #include "mylib.h" typedef struct q_item *q_item; struct q_item { double item; q_item next; }; struct queue { q_item first; q_item last; int length; }; queue queue_new() { queue result = emalloc(sizeof * result); resu...
C
#include <stdio.h> #include <stdlib.h> #include <pthread.h> #define NUM_THREADS 2 typedef struct _thread_data_t { int tid; double stuff; } thread_data_t; void *thr_func(void *arg){ thread_data_t * data = (thread_data_t *)arg; printf("HI id: %d\n", data->tid); pthread_exit(NULL); } int main(void){ pthread...
C
#include "myMath.h" #include <stdio.h> int main(){ double x; printf("Please inset a real number: "); scanf("%lf", &x); //f(x) = e^x + x^3 − 2 double y = sub(add(Exponent(x), Power(x,3)),2); printf("\nThe value of f(𝑥) = 𝑒^𝑥 + 𝑥^3 − 2 at the point %lf is: %.4lf", x, y); //f(x) = 3x + 2...
C
#include <stdio.h> #include <stdlib.h> #include "list.h" int main(){ struct node *s = (struct node *)malloc(sizeof(struct node)); //(*(*s).next).i = 'b'; print_list(s); s = insert_front(s,'a'); print_list(s); s = insert_front(s,'b'); print_list(s); s = free_list(s); printf("Pointer to s:[%p]\n",s); ...
C
#include <stdio.h> #include <stdlib.h> #define ERROR 1e8 typedef int ElementType; typedef enum { push, pop, end } Operation; typedef struct StackRecord *Stack; struct StackRecord { int Capacity; /* maximum size of the stack array */ int Top1; /* top pointer for Stack 1 */ int Top2; /* top ...
C
#ifndef UTN_H_INCLUDED #define UTN_H_INCLUDED /// PRINCIPALES /** \brief Obtiene un string * * \param message char* El mensaje a mostrar * \param messageError char* El mensaje de error a mostrar * \param min int El tamao minimo * \param max int El temao maximo * \param tries int* Intentos que tiene e...
C
// 20. Write a program to display // a. Prime numbers between 1 to 100 // b. Armstrong Numbers between 1 to 500s #include<stdio.h> void main() { int i,j,LR,HR; printf("Enter the range "); scanf("%d %d",&LR,&HR); for(i=LR; i<=HR; i++) { for(j=2; j<i;j++) { if(i%j==0) break; } if(j==i) printf(...
C
#include <stdio.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <errno.h> #include <string.h> #include <stdlib.h> #define PRINT_ERR(mess)(perror(mess);printf("errno=%d\n",errno);exit(-1)) #define FAILE(mess)(fprintf(stdout,"%s:%s\n",mess,strerror(errno))) /*nonblock to r...
C
#include <stdio.h> char* intToRoman(int num) { int roman[13] = { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 }; char* res = (char*)malloc(sizeof(char) * 55); int i = 0; while (num != 0) { int j = 0; while (j < 13) { if (num >= roman[j]) { ...
C
#include "history.h" const int HISTORY_AMOUNTS[NUM_HISTORY_COUNTS] = {8, 16, HISTORY_SIZE - 1}; void addHistory( History *history, char currentState ) { int i; unsigned char *irHistory; int historyIndex; irHistory = history->irHistory; currentState = ( currentState ? 1 : 0 ); history->curren...
C
/** * uki.c * A micro-wiki for personal stuff. * * @author: Nathan Campos <nathan@innoveworkshop.com> */ #define UKI_DLL_EXPORTS #include "uki.h" #include "fileutils.h" #include <stdlib.h> #include <stdio.h> #include <string.h> #ifdef UNIX #include <stdbool.h> #endif // Private variables. char *wiki_root; bool u...
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { FILE *f1, *f2; //pointers to two files char buffer[10]; size_t data; //read from file1 the source file f1 = fopen(argv[1], "r"); //test to see if file can be opened or not if(argc <2) { printf("Not enough arguments!"); exit(0); ...
C
#ifndef __LinkedList_C #define __LinkedList_C #include <stdio.h> #include <stdlib.h> #include "linkedList.h" Node *newNode( GraphNode *graphNode ) { Node *newNode = (Node *) malloc( sizeof( Node ) ); newNode->node = graphNode; newNode->next = NULL; newNode->prev = NULL; return newNode; } void app...
C
#include "holberton.h" /* * Function that prints 1 is n is prime * 0 is not prime */ int is_prime_number(int n) { int k; k = n / 2; if (n <= 1) return (0); else return (checkprime(n, k)); } /* * function to check is n given is prime */ int checkprime(int n, int k) { int i = 1; if (k == 1) { i = 1; } else i...
C
#include "PLL.h" #include "tm4c123gh6pm.h" void DisableInterrupts(void); // Disable interrupts void EnableInterrupts(void); // Enable interrupts void WaitForInterrupt(void); // low power mode void PortA_Init(void); // start sound output void SysInit(void); //initialize SysTick timer void SysLoad(u...
C
/* ============================================================================ Name : homework3-2.c Author : Ji Un Song Version : Copyright : Description : ap2.c ============================================================================ */ #include <stdio.h> #include <stdlib.h> int main(v...
C
/** * COSC 3250 - Project 8 * Test cases for process messages * @authors Danny Hudetz Marty Boehm * Instructor Rubya * TA-BOT:MAILTO daniel.hudetz@marquette.edu martin.boehm@marquette.edu */ #include <xinu.h> /** * testcases - called after initialization completes to test things. */ void receiveMsg(void) { ...
C
#include <stdio.h> #include <time.h> #include "gconio.h" const int fogoLargura = 18; const int fogoAltura = 18; void rederizaFogo(int fogotab[]){ int pont = 0; for(int y = 0; y < fogoAltura; y++){ for(int x = 0; x < fogoLargura; x++){ textbackground(fogotab[pont] % 7); printf("...
C
#include <stdio.h> #include <netdb.h> #include <sys/socket.h> #include <sys/utsname.h> main() { //ҪЧ,Ա/etc/hostsû sethostent(1); struct hostent *ent; while(1) { ent = gethostent(); if(!ent) break; printf(":%s:%hhu.%hhu.%hhu.%hhu\n", //printf(":%s:%u.%u.%u.%u\n", ent->h_name, ent->h_addr[0], ...
C
#include <stdio.h> #include <sys/types.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <signal.h> #define MAX_INPUT_SIZE 1024 #define MAX_TOKEN_SIZE 64 #define MAX_NUM_TOKENS 64 #define RD_WR 0666 char* server_ip; char* server_port; int server_set; volatile sig_atomic_t ke...
C
// ============================================================================= // // Polonator G.007 Image Processing Software // // Church Lab, Harvard Medical School // Written by Greg Porreca // // Release 1.0 -- 02-12-2008 // // This software may be modified and re-distributed, but this header must appear // at ...