language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include <stdio.h> #include <stdlib.h> #define ll long long int #define N 10001 ll harr[N]; int size = 0; int frq[N] = {0}; void swap(ll *a, ll *b) { ll temp = *a; *a = *b; *b = temp; } void maxHeapify(int i) { if (size == 1) return; if (i >= size / 2) return; int largest = i; int left...
C
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]) { FILE *fp; char str[50]; int number, year, month, day, EOF_flag = 0; double price; if (argc != 2) { printf("usage: reader file"); exit(EXIT_FAILURE); } if ((fp = fopen(argv[1], "r")) == NULL) { fprintf(stderr, "Can't open file ...
C
#include<stdio.h> int main() { int a; for(a=0;a<10;a++) { a +=2; if(a>=10) break; a-= 1; } printf("%d\n",a); return 0; }
C
/* * hal_time.c * * Description: contains the stm32-implementation of the hardware * abstraction layer interface for time-related functionality * */ #include "platform/hal_time.h" #include "platform/hal_semaphore.h" #include <hwf4/timer.h> #include <FreeRTOS.h> #include <stdlib.h> #include <stdio.h> #include ...
C
//-------------------------------------------------------------------------------------------------- /// XML // /// : /// 2012 //----------------------------------------------------------------------------------------------- #ifndef INCLUDE__XML_H #define INCLUDE__XML_H #include <string.h> #include <stdl...
C
/************************************************************************* > File Name: 18.MAX.c > Author: > Mail: > Created Time: Wed 26 May 2021 03:39:45 PM CST ************************************************************************/ #include <stdio.h> #define P(a) { \ printf("%s = ", #a); printf("%d\n", (...
C
/************************************************************************* > File Name: ver_cmp.h > Author: Joenan > Mail: joenan.woo@gmail.com > Created Time: Thu Feb 1 01:16:47 2018 ************************************************************************/ #include <stdio.h> #include <ctype.h> #include <str...
C
//-------------------------------------------------------------------------* // ļ: gpio.c * // ˵ : gpioļ * //-------------------------------------------------------------------------* #include "gpio.h" /**********...
C
#include<stdio.h> int main() { //ҲһԶ int arr[10] = { 0 }; printf("%d\n", sizeof(arr)); //40 printf("%d\n", sizeof(int[10])); //40 int a = 10; sizeof(int); //Ե sizeof(a); //Ե //ôˣʲôأ //ͣȥʣµIJ // int arr[10],ô;int [10] } #include<stdio.h> void test() { printf("hehe"); } int main() ...
C
int g[5]; int get(int array[], int index) { return array[index]; } int pointerize(int ref[]) { return get(ref, 3); } void main(void) { int e[5]; e[3] = 69; g[3] = 69; output(g[3]); output(pointerize(g)); output(e[3]); output(pointerize(e)); }
C
#include <stdio.h> char map[1010][1010]; int m, n; int alive; void water(int r, int c); int main() { int i, j, erow, ecol; scanf("%d%d", &m, &n); for (i=0; i<m; i++) { scanf("%s", &map[i]); } for (i=0; i<m; i++) { for (j=0; j<n; j++) { if (map[i][j]=='e') { ...
C
/* Code eval challenge: Prime Palindrome Author: Ravi Niure Linkedin/twitter: niurerav Department of Electrical and Computer Engineering University of Toronto */ /* Problem Statement: Write a program which determines the largest prime palindrome less than 1000. Input: No input Output: Print to stdout the ...
C
#include "stencil.h" //The row/col sizes specified in SHOC: //{512, 1024, 2048, 4096} void stencil (int *orig, int *sol, int const *filter) { int i, j,k1, k2, sidx, didx, fidx; int tmp, Si, SI, Di, Ti; for (i=0; i<32; i++) { for (j=0; j<32; j++) { Si = 0; SI = 0; tmp = 0; fidx = 0; SI = i * 34; ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <pthread.h> void error(const char *msg){ perror(msg); exit(1); } void *SocketThread (int threadSockfd){ char threadBuffer[256]; // 255 letters coul...
C
#include <stdlib.h> #include <stdio.h> #include <math.h> #include <string.h> #include "globais.h" #include "page.h" #include "tabela.h" #include "memoria.h" #include "funcoes.c" int main(int argc , char **argv) { //Variaveis int tamanho_pagina,tamanho_memoria,qnt_paginas; unsigned addr; char rw; page* t...
C
/* This file is for Benes network related functions */ #include "util.h" #include "..\ref\transpose.h" #include "..\ref\params.h" #include "benes.h" /* middle layers of the benes network */ static void layer_in(uint64_t data[2][64], uint64_t * bits, int lgs) { int i, j, s; uint64_t d; s = 1 << lgs; for (i = ...
C
#include <stdio.h> float temp_c; float temp_f; int main(int argc, char const *argv[]) { // argc is 'argument count' - the number of arguments // argv is 'argument vector' if (argc < 2) { printf("Provide an integer argument.\n"); return 1; } sscanf(argv[1], "%f", &temp_c); temp_...
C
// This file is part of the B library, which is released under the MIT license. // Copyright (C) 2002-2007, 2016-2020 Damon Revoe <him@revl.org> // See the file LICENSE for the license terms. B_BEGIN_NAMESPACE size_t string_view::find(char_t ch) const { const char_t* ptr = view; for (size_t counter = view_length; ...
C
#include <stdio.h> int main(void) { int i, j; int a, b; puts("長方形をつくります"); printf("一辺:"); scanf("%d", &a); printf("一辺:"); scanf("%d", &b); if (a < b) { for (i = 1; i <= a; i++) { for (j = 1; j <= b; j++) { putchar('*'); } putchar('\n'); } } else { for (i = 1; i <= b; i++) { ...
C
/*GHERGU MIHAI ADRIAN 331CB*/ #include <stdio.h> #include <string.h> #include <math.h> #include <stdlib.h> #include <pthread.h> #include <complex.h> struct myStr{ int step; double complex *input; double complex *output; int th_id; }; int N, numThreads; pthread_t *tid; complex double *inValues; ...
C
#include <stdio.h> #include "main.h" uint8_t flag1 =0; uint8_t flag2 =0; void gpio_init(void); void exit_init(void); void Delay(__IO uint32_t num); int main(void) { gpio_init(); exit_init(); while(1) { if(flag1==0) GPIO_SetBits(GPIOC,GPIO_Pin_7); else GPIO_ResetBits(GPIOC,GPIO_Pin_7); if(flag2==0) ...
C
#include "purest_json.h" static t_class *json_encode_class; void setup_json0x2dencode(void) { json_encode_class = class_new(gensym("json-encode"), (t_newmethod)json_encode_new, 0, sizeof(t_json_encode), 0, A_GIMME, 0); class_addbang(json_encode_class, (t_method)json_encode_bang); class_addmethod(json_encode_clas...
C
#include "../header.h" void signal_handle(int v) {} int main() { // 告诉内核,当SIGHUP信号发生时,调用signal_handle signal(SIGHUP, signal_handle); while(1) { sleep(1); } //getchar(); // 不能演示SIGHUP的原因是因为getchar和终端有关系 return 0; }
C
/************************************************************************\ * INET_WSTREAM.C * * Test of TCP/IP. Invoke as * * inet_wstream hostname portnumber * * in order to send a fragment of an obnoxious Dijkstr...
C
// // Created by lishoulin on 18/4/8. // #include <stdio.h> int main() { for (int i = 1; i <= 9; i++) { for (int j = 1; j <= i; j++) { printf("%d * %d = %d ", i, j, i * j); } printf("\n"); } printf("double * \n"); double x, y, z; x = 10.1; y = 1.21; ...
C
/* * MercatorProj.c *墨卡托投影算法 * Created on: Apr 18, 2019 * Author: wanji-hxy */ #include "MercatorProj.h" const double __IterativeValue = 10; //反向转换程序中的迭代初始值 const double __A = 6378137; //椭球体长半轴,米 const double __B = 6356752.3142; //椭球体短半轴,米 double __B0; //标准纬度,弧度(取激光雷达所在纬度) double __L0; //原点经度,弧...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include "plateau.h" partie_t* partie_creer(void){ int i; partie_t* res = malloc(sizeof(partie_t)); res-> echiquier = malloc(8*sizeof(char*)); for(i = 0; i < 8; i++) res-> echiquier[i] = malloc(8*sizeof(char)); res-> capture = pile_cree(); ...
C
// Copyright 2014, Schmidt #include <stdbool.h> #include "lex.h" #include "process.h" #include "hash.h" #include "print.h" #include "wordcmp.h" #include "hash.h" #include "rand/rand.h" #define MIN(x,y) (x<y?x:y) static void *vptr; static bool ngram_check_ngram_for_null(ngram_t *ng) { wordlist_t *wl = ng->words...
C
/* Programming Challenge from Evernote Website Given a list of integers, your task is to write a program to output an integer-valued list of equal length such that the output element at index 'i' is the product of all input elements except for the input element at 'i'. In other words, let inputArray by an integer ...
C
// Grafico de desplazamiento. #include "grafdesp.h" #include "grafico.h" #include "grafico.syh" #include "memory.h" #include "asrtbas.h" struct i_desplazamiento_t { struct grafico_t *grafico; double dx, dy; }; //--------------------------------------------------------- static struct i_desplazamiento_...
C
#include<stdio.h> #define TRUE 1 #define FALSE 0 void prime(int inum) { int i=2; while(i<inum/2 && inum%i!=0 ) i++; if(inum==1 || inum==4) printf(" "); else if(i>=inum/2) printf("%d is prime\n",inum); } int main() { int istart=0,iend=0,ians=0; printf("en...
C
//g. To determine the larger of two given numbers. #include <stdio.h> int main() { int a, b; printf("Enter two number :"); scanf("%d%d", &a, &b); if (a > b) { printf("%d is the larger of two given numbers", a); } else { printf("%d is the larger of two given numbers", b);...
C
/* * button.c * * Created on: Jan 24, 2017 * Author: bdknox */ #include "RBELib/RBELib.h" #include "avr/io.h" #include <RBELib/reg_structs.h> #include <avr/interrupt.h> #include "button.h" int buttonState; int prevButton; signed int angle; signed int prevAngle; void initButtons(){ // D...
C
#include "scr_rdma_transfer.h" #include "rdma-server.h" #include <string.h> #include <fcntl.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/time.h> #ifndef TABLE_LEN #define TABLE_LEN (1000) #endif static double get_dtime(void); struct file_path { int tag; char path[1024]; int flag...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* parse_type_x.c :+: :+: :+: ...
C
#include <pthread.h> #include <stdio.h> #include <stdbool.h> #include <stdlib.h> #include <unistd.h> #include <signal.h> #include <time.h> #include <mqueue.h> #include <string.h> #include <errno.h> #include <stddef.h> #include <assert.h> #include <inttypes.h> #define THREAD_POOL_NAME "/thread_pool_test" #define NUM_TH...
C
/* (C) 1999, Arthur Vargas Lopes */ /* Arquivo fonte Contagem.c */ #include "contagem.h" /* Algoritmo 8.9 */ void Contagem(int V[], int N) { int *R; int *T; int I, M = 0, P; for(I = 0; I < N; ++I) if (V[I] > M) M = V[I]; R = (int *) calloc(N,sizeof(int)); if (R == NULL) { printf("*** Contagem: f...
C
#include <stdio.h> #include <stdlib.h> int main() { char a[5]; scanf("%s",a); int i,j,n,occ=0,occ_max=0,len1=strlen(a),flag=1; scanf("%d",&n); while(--n>=0){ char b[10]; scanf("%s",b); int len2=strlen(b); for(i=0;i<=len2-len1+1;++i){ for(j=0;j<len1;++j){ ...
C
/* * my_assembler Լ ũθ ִ ̴. * */ #define MAX_INST 256 #define MAX_LINES 5000 #define MAX_OPERAND 3 //߰κ( ȣ) #define X 1 #define A 0 #define S 4 #define T 5 /* * instruction Ϸ ޾ƿͼ ϴ ü ̴. * ϳ instruction Ѵ. */ struct inst_unit { char str[10]; unsigned char op; int format; int ops; }; typedef s...
C
#include "push_swap.h" static t_stack *new_element(long long number) { t_stack *new; if (number < -2147483648 || number > 2147483647) return (NULL); if (!(new = (t_stack *)malloc(sizeof(t_stack)))) return (NULL); new->cell = (int)number; new->next = NULL; return (new); } static int fill_from_str(t_pushs...
C
#include <stdio.h> #include <stdlib.h> int plus(int x, int y) { return x + y; } void sumstore(int x, int y, int *dest) { int t = plus(x, y); *dest = t; } int main(int argc, char* argv[]) { long x = atoi(argv[1]); long y = atoi(argv[2]); long z; sumstore(x, y, &z); printf("%ld + %ld --...
C
#include "test.h" int main() { int a = 0, b = 2, c = 3; printf("2 + 3 = %d\n",sum(b, c)); printf("2 - 3 = %d\n",sub(b, c)); printf("2 * 3 = %d\n",mult(b, c)); return 0; } int sum(int sum1, int sum2) { return (sum1 + sum2); } int sub(int sub1, int sub2) { return (sub1 - sub2); } int mult(int mult1, int mult2)...
C
#include<stdio.h> #include<unistd.h> #include<sys/types.h> int main() { pid_t pid ; int fd1[2], fd2[2] ; pid = fork() ; pipe(fd1) ; pipe(fd2) ; if(pid == -1) { perror("fork error"); return 0 ; } int flag = 0 ; int num1 = 1 ; int num2 = 2 ; int signal = 3 ; while ( num1 < 1...
C
#include "dft.h" #include <math.h> #include <stdio.h> #include <stdlib.h> #include <complex.h> #define pi 3.14159265358979323846 //gcc .\USAGE_of_dft.c .\dft.c -o .\USAGE_of_dft.exe void error() { printf("error!"); } void main() { float *signal; int length = 8; float inkrement = 2*pi/length; flo...
C
/* Malloc unit test * * Don Porter - COMP 530 - UNC Chapel Hill * * This utility allocates and frees memory in different patterns, keeping * track of the requested sizes, overwriting with junk, and looking for errors * or inconsistencies. */ #include <assert.h> #include <signal.h> #include <stdbool.h> #include ...
C
/* func3.c */ #include <stdio.h> void func1(void); void func2(void); void func3(void); void func1(void) { printf("Ich bin func1 \n"); func3(); } void func2(void) { printf("Ich bin func2 \n"); } void func3(void) { printf("Ich bin func3 \n"); func2(); } int main(void) { func1(); return 0; }
C
#include <stdio.h> #include <stdlib.h> int convStoI(char T[]) { int nb = 0; int i = 0; while(T[i] >= '0' && T[i] <= '9') { nb = nb*10+(T[i]-'0'); i++; } return nb; } int main(int argc, char* argv[]) { if(argc != 2){ printf("inserer arg SVP\n"); return 1; } printf("Ma conver...
C
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include "protocol.h" #include "error.h" int send_command(int socket, struct command_frame *frame){ unsigned char frame_array[2]; frame_array[0] = frame->command; frame_array[1] = frame->parameter; if ((write(socket, fr...
C
int lengthOfLongestSubstring(char* s) { int arr[256]; int st = 0, ed = 0; int max = 0; memset(arr, -1, sizeof(arr)); while (s[ed] != 0) { char ch = s[ed]; if (arr[ch] != -1) { // repeated found if (ed - st > max) { max ...
C
// // main.c // TestOCR // // Created by Pierre Pelletier on 02/10/2019. // Copyright © 2019 Pierre Pelletier. All rights reserved. // #include <stdio.h> #include <SDL2/SDL.h> #include <SDL_image.h> int loadimage(char *filename); void BlackAndWhite(SDL_Surface* surface); void MonoColor(SDL_Surface* surface); void...
C
/** * @brief It defines common types interpreter * * @file types.h * @author Ana Roa González * @version 1.0 * @date 13-01-2018 */ #ifndef TYPES_H #define TYPES_H #define WORD_SIZE 1000 #define NO_ID -1 /** * @brief Definicicion de tipo Id */ typedef long Id; /** * @brief Lista del Tipo Booleano */ typedef...
C
#include <stdio.h> int main() { // The questions says, you need to find number of food packets that can be distributed equally between x numbers (here messcnt) // Understand this as you need to share 3 chocolates between 2 people equally this way you can distribute 2 equally, 1 will be left over. int avlqntoffoo...
C
#include <stdio.h> #include <stdlib.h> /* * a QUEUE is a FIFO * * a queue is always imagined as a horizontal line unlike * a stack which is always imagined as a vertical line * * ---------------------------------- * front rear * * a queue is always operated from both ends unlike ...
C
#include <avr/pgmspace.h> #include "nokia5110.h" /*https://components101.com/nokia-5110-lcd http://www.electronicwings.com/avr-atmega/nokia5110-graphical-display-interfacing-with-atmega16-32 * https://github.com/LittleBuster/avr-nokia5110/blob/master/nokia5110.h */ static struct { uint8_t screen[504]; uint8_t curs...
C
// NOTE: compile and link with -lpthread #include <pthread.h> #include <string.h> #include <errno.h> #include <stdio.h> #include <stdlib.h> #define MAX_BUF_SIZE 5 // global count variables; struct pt_args { int buf_count; char buffer[MAX_BUF_SIZE]; }; // consumer function void *consume( void* arg ) { ...
C
#include<stdio.h> #include<math.h> #include<stdlib.h> #define prcn 0.000001 //problem functions============================================================ //f(x)------------------------------------- double f(double x) { return (x*x-x-6); } //f'(x)------------------------------------ double fd(double x) { return (2...
C
#include <stdio.h> #include "logexp.h" int main() { double k; float l; long double m; k = mylog(6.2345); printf("%lf\n",k); l = mylogf(0.4562); printf("%f\n",l); m = mylogl(-10); printf("%Lf\n",m); k = mylog(1); printf("%lf\n",k); return 0; }
C
#include<stdio.h> #include<stdlib.h> int main() { char a[100]; int c=0; scanf("%s",a); for(int i=0;i<strlen(a);i++) { if((!isalpha(a[i])||(a[i]>='0' && a[i]<=9))) { c++; } } printf("%d",c); }
C
#include "reverse_hex_digits.h" /** Reverse hex digits in an integer */ /** reverse hex digits in a byte, 0x12 => 0x21 */ uint8_t reverse8(uint8_t x8) { return ((x8 << 4) | (x8 >> 4)); } /** reverse hex digits in a 32-bit word, 0x1234 => 0x4321 */ uint16_t reverse16(uint16_t x16) { return (reverse8(x16 & 0xFF) ...
C
//program which accepts Directory name from user and write information of all the regular file in and read from that file. #include<stdio.h> #include<fcntl.h> #include<unistd.h> #include <sys/stat.h> #include <malloc.h> #include <dirent.h> int main(int argc, char* argv[]) { int fd = 0; struct stat fileStat; ...
C
#include "builtin.h" char *builtin_str[] = { "exit", "jobs", "kill", "resume", "sleep", "suspend", "wait" }; int shell_num_builtins() { return sizeof(builtin_str) / sizeof(char *); } void shell_exit() { FILE *fp; char *pid_stat[64]; char *token; int status; long u...
C
#ifndef __2DVECTOR_H_ #define __2DVECTOR_H_ /* * tiny 2d vector library (for bezier curves) */ #include "bezier.h" // for BEZ_STEPS #include "fontheader.h" // for point_t #include "Utils.h" // for sqrti #include <stdlib.h> inline point_t padd(const point_t a, const point_t b){ point_t r; r.x = a.x + b.x; ...
C
#include"stdafx.h" #include<stdio.h> #include"vector.h" #include<math.h> /* ߶Σֵ */ float point_interp(float t, float x, float y) { return x + t * (x - y); } /* ģ */ float vector_length(vector v) { return sqrt(v.x * v.x + v.y * v.y + v.z * v.z); } void vector_add(vector* out, const vector a, const vect...
C
#include "holberton.h" /** * print_line - make a line * @n: a number * Return: void */ void print_line(int n) { int p = 0; while (p < n) { _putchar('_'); p++; } _putchar('\n'); }
C
/*Write a program using a whileloop to display the numbers 1 -10 in descendingorder on the same line and each number separated by a comma (e.g. 10,9,8,7,6,5,4,3,2,1). Auhtor: Adlane Boulmelh Date: 21/10/2019 */ #include <stdio.h> int main() { int i =10; while(i>=1) { printf("%d", i); ...
C
#include <stdio.h> #include <stdlib.h> #include "quotient.h" #include "main.h" void quotient(void) { int m, n; puts("Введите 2 числа"); scanf("%i%i", &m, &n); puts(""); char* buffer = (char*) calloc(1000, sizeof(char)); put_result_to_array(buffer, m, n); puts(buffer); free(buffer); ...
C
// Tanda 1, Actividad 4: Generar una estructura con un proceso padre y 3 hijos #include<stdlib.h> #include<unistd.h> #include<stdio.h> #include<sys/wait.h> void main() { pid_t pid,pid_hijo_1,pid_hijo_2,pid_hijo_3; //Creacion del primer hijo pid = fork(); if(pid == -1) { printf("No se ha pod...
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
#ifndef ITEMS_H #define ITEMS_H struct ITEM_TYPE { char p_szName[18]; int nCost; bool bStackable; int nStackSize; }; ITEM_TYPE sItems[] = { { "", 0, false, 0 }, // (0) cnItemNone { "Herb", 24, true, 6 }, // (1) cnItemHerb { "Wings", 70, false, 0 }, // (2) cnItemWings { "Torch", 8, false, 0 }, ...
C
#include <stdio.h> #include <math.h> #include <stdlib.h> int main(void) { double mealCost; int tipPerc; int taxPerc; scanf("%lf %d %d", &mealCost, &tipPerc, &taxPerc); double total = mealCost+ mealCost*(tipPerc+taxPerc)/100; printf("The total meal cost is %d dollars.", (int)round(total)); ...
C
#ifndef LINKED_LIST_QUEUE_H #define LINKED_LIST_QUEUE_H #include <stdio.h> #include <stdlib.h> #include "ALGraph.h" typedef struct alg_vertex_t* llq_element_type_t; typedef struct _llq_node { llq_element_type_t data; struct _llq_node* next; } llq_node_t; typedef struct _llq_queue { llq_node_t* head; llq_node_t*...
C
#include<stdio.h> void foo(int v1) { printf("data : %d \n",v1); } void foo(char * v1) { printf("data : %s \n",v1); } int main() { printf("START\n"); foo(1); foo2("string data"); return 0; }
C
#include <stdio.h> main() { int numAgencia; int m, c, d, u; int dv; printf("Entre com o numero da Agencia\n"); scanf("%d", &numAgencia); m = numAgencia / 1000; c = (numAgencia % 1000) / 100; d = (numAgencia % 100) / 10; u = numAgencia % 10; dv = (2 * u) + (3 * d) + (4 * c) + (5 * m); d...
C
#include <unistd.h>; #include <sys/types.h>; main () { pid_t pid; printf("fork!"); // printf("fork!n"); pid=fork(); if (pid < 0) printf("error in fork!"); else if (pid == 0) printf("i am the child process, my process id is %dn",getpid()); else printf("i am the parent process, my process id is %dn",getpid(...
C
#include "ipw.h" #include "pgm.h" int main( int argc, char **argv) { static OPTION_T opt_i = { 'i', "input image file", STR_OPTARGS, "image", OPTIONAL, 1, 1 }; static OPTION_T opt_l = { 'l', "lookup table file", STR_OPTARGS, "LUT", OPTIONAL, 1, 1 }; static OPTION_T *optv[] = ...
C
/******************************************************************************************* * Programmer: Freya * * Class: CptS 121, Spring 2018; Lab Section 10 * * Programming Assignment: PA3 ...
C
#include <stdio.h> #include <stdbool.h> #include <sys/statvfs.h> #include "cerver/system.h" // get available space (bytes) in a given filesystem // returns true on success, false on error bool system_get_available_space ( const char *path, unsigned long *available_space ) { bool retval = false; struct statvfs s...
C
../KEYP/encode.c
C
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #include <string.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> /*close*/ #define SERVER_PORT 1500 #define MAX_MSG 100 int main(int argc, char *argv[]) { int sd, rc, i; struct sockad...
C
#include <stdio.h> #include "contacts.h" #include "contactHelpers.h" void getContact(struct Contact *contact) { int getNum; printf("Please enter the contact's first name: "); scanf(" %30[^\n]s", contact->name.firstName); printf("Do you want to enter a middle initial(s)? (y or n): "); clearKeyboard(); ...
C
/* 函数名: strcmp 功 能: 串比较 用 法: int strcmp ( char *str1, char *str2); 看Asic码,str1>str2,返回值 > 0;两串相等,返回0 */ #include <string.h> #include <stdlib.h> #include <stdio.h> int main( void ) { char *buf1 = "aaa" , *buf2 = "bbb" , *buf3 = "ccc" ; int ptr; ptr = strcmp (buf2, buf1); if (ptr > 0) printf ( "bu...
C
// C program to illustate fgetc() function #include <stdio.h> int main () { // open the file FILE *fp = fopen("test.txt","r"); // Return if could not open file if (fp == NULL) return 0; do { // Taking input single character at a time char c = fgetc(fp); // Checking for end of file if (feof(fp)) br...
C
#include <stdio.h> int main() { int num; printf("enter the number \n"); scanf("%d", &num); if (num% 90 == 0) { printf("YES"); } else { printf("NO"); } }
C
#include "holberton.h" /** * cap_string - capitalises all words *@s: string *Return: s */ char *cap_string(char *s) { int i; char j[30] = ",;.!?\" (){}\t\n"; int k; for (i = 0; s[i] != '\0'; i++) { if (s[i] >= 97 && s[i] <= 122) { for (k = 0; k < 14; k++) { if (s[i - 1] == j[k]) { s[i] = s[...
C
#include "eep_memmap.h" #include "eep_Manage.h" #include "DeviceOD.h" //---internal variable of the OD ------------------------------------------------------------------ //--1. Data memory of the object dictionary-- uint32 ODMem[ODMemLength]; //--2. Memory mapping for object dictionary-- /*----------------------------...
C
// compile: clang -fopenmp test2.c -o test // triggers warnings about __kmpc_* series function calls, but works #include <stdio.h> #include <stdlib.h> #include <unistd.h> // extern ..... void init(float *a, int N); void axpy_omp_parallel_for_gpu(int *gtid, int *btid, const float a, float *A, const float *B, float ...
C
#include <stdio.h> #include <stdlib.h> #define MAX 1200 int main(int argc, char *argv[]) { FILE *dest, *src; int i; char buffer[MAX]; if(argc < 4) { puts("Mod de utilizare al programului: p73.exe fisier_dest fisier_sursa1 fisier_sursa2 ..."); exit(1); ...
C
#include <stdio.h> #include <stdlib.h> struct matrix{ char direction[20]; int coordinate; }; void inputStructure(struct matrix *); void pStruct(struct matrix *); void printStructure(struct matrix *, int); int main (void) { int stp; int i; int num; struct matrix *moon; printf("Enter number of points ...
C
// Copyright (C) 1994 The New York Group Theory Cooperative // See magnus/doc/COPYRIGHT for the full notice. // Contents: Definition and implementation of class Int2 // // Principal Author: Dmitry Bormotov // // Status: temporary // // Revision History: #ifndef _Int2_H_ #define _Int2_H_ #include "g...
C
#include "holberton.h" #include <stdio.h> /** * errorMsg - Print error message * @exitCode: exit code to stop * @msg: the error message to be printed * @fileName: the name of the file */ void errorMsg(int exitCode, const char *msg, const char *fileName) { dprintf(STDERR_FILENO, "%s %s\n", msg, fileName); exit(ex...
C
/* Demonstrates an array of structs and pointer to struct. * Shows the difference between the "." and the "->" operators. */ #include <stdlib.h> #include <stdio.h> typedef struct { char name[80]; double average; double shoeSize; } BowlingRecord; // } BowlingRecord, *BowlingRecordPtr; int main(){ Bow...
C
#ifndef A32_CONVERT_H #define A32_CONVERT_H /** * Trim leading and trailing whitespace of a string. * * Note: The function will modify the passed string. * * @param str The source string. * @return The trimmed string */ char* a32_trim(char* str); /** * Returns a string containing the value. * * Note: The re...
C
/* - tmexec.c -- - Spawn a child process. Try to kill it later. - . Usage: . tmexec seconds command [arg arg ...] . . Program will execute command, and send it a SIGTERM signal after . seconds. Return value will be return value of command. . . Copyright (c) 2012, Gordon D. Carrie. All ri...
C
// By default the 1607 has a 20MHz CPU divided by 6 to give 3.3 MHz #define F_CPU 3300000 // For basic pin operations #include <avr/io.h> // For the delay function #include <util/delay.h> // Main program starts here int main(void) { // Set the PORTB pins to work as outputs PORTB_DIR = 0xff; // Do this forever...
C
#include<stdio.h> int main() { int i=0,j=0,inmax=0,inmin=0,n; int max=0,min=11111,sum=0; scanf("%d",&n); int ar[110]; for(i=0;i<n;i++) scanf("%d",&ar[i]); for(i=0;i<n;i++) { if(ar[i]>max) { max=ar[i]; inmax=i; } ...
C
#include <stdlib.h> #include <string.h> #include <stdio.h> #include "lists.h" /** *get_dnodeint_at_index - Function to return an nth node *@head: pointer to the head of the list *@index: index of the node, starting from 0 *Return: the nth node or NULL */ dlistint_t *get_dnodeint_at_index(dlistint_t *head, unsigne...
C
#include<stdio.h> #include<conio.h> #include<string.h> #include<stdlib.h> #include<time.h> int main() { struct tm t; time_t timeinc; t.tm_year = 2016-1900; t.tm_mon = 1; t.tm_mday = 22; t.tm_hour = 0; t.tm_min = 0; t.tm_sec = 0; t.tm_isdst = 0; // day light saving timei...
C
#ifndef UO_REFSTACK_H #define UO_REFSTACK_H #ifdef __cplusplus extern "C" { #endif #include "uo_refcount.h" #include "uo_stack.h" typedef struct uo_stack uo_refstack; /** * @brief create an instance of uo_refstack * * uo_refstack is used for grouping resources that should be finalized together. * The order of ...
C
#include "curl_setup.h" #include <curl/curl.h> #include "hash.h" #include "llist.h" #include "curl_memory.h" #include "memdebug.h" static void hash_element_dtor(void *user, void *element) { struct curl_hash *h = (struct c...
C
#include "holberton.h" #include <stdio.h> int _strcmp(char *, char *); /** * print_pointer - Print a number in hexadecimal format * @list: Number to print * * Return: Length of the number **/ int print_pointer(va_list list) { char *p_buff; int size; p_buff = itoa(va_arg(list, unsigned long int), 16); if (!...