language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#include "ctrl.h" #include "list.h" #include <linux/kernel.h> #include <linux/types.h> #include <linux/fs.h> #include <linux/device.h> #include <linux/slab.h> #include <asm/errno.h> struct ctrl* ctrl_get(struct list* list, struct class* cls, struct pci_dev* pdev, int number) { struct ctrl* ctrl = NULL; ctrl...
C
#include <string.h> int strncmp (const char *s1, const char *s2, size_t n) { while (n > 0 && *s1 && *s2 && *s1 == *s2) n--, s1++, s2++; return n == 0 ? 0 : (int)*s1 - (int)*s2; }
C
/*! ---------------------------------------------------------------------------- * @file main.c * @brief RX using double buffering example code * * This example keeps listening for any incoming frames, storing in a local buffer any frame received before going back to listening. This * ex...
C
#include "AVL.h" #include <malloc.h> #include <math.h> #include <stdio.h> #include <stdlib.h> int max(int a, int b) { if (a > b) { return a; } return b; } int getHeight(Node *node) { int x, y; if (node == NULL) { return -1; } x = getHeight(node->left); y = getHeight(node->right); ...
C
#include <stdio.h> void InsertionSort(int *start,int *end) { for(int *i = start + 1; i!= end;i++) { for (int *j = start; j < i ; j++) // the code is not optimized; After the short is found, you should not go to the j-1 entry level { if( *i < *j) { int key = *j; *j = *i; ...
C
#include "analex.h" #include "anasin.h" #include "gerenciador.h" int indice=0; int variavelDeclaraAtrib(){ int aux,troca; aux = topo; troca = 0; if (tk.cat == ID){ if (escopo == 1){ while (aux > 0){ if (troca == 1){ if (...
C
//#define _CRT_SECURE_NO_WARNINGS 1 // //#include <stdio.h> //#include <math.h> // //int main() //{ // int n = 0; // int f1 = 0; // int f2 = 1; // int f3 = 0; // while (1) // { // if (n == f2) // { // printf("0\n"); // break; // } // else if (n < f2) // { // if (abs(f1 - n) < abs(f2 - n)) // { // printf...
C
#include "holberton.h" #include <stdio.h> /** * print_number - prints an integer * @n: integer to be printed * Return: Nothing */ void print_number(int n) { char last_digit; int rev; if (n < 0) { _putchar('-'); last_digit = ('0' - (n % 10)); n /= -10; } else { last_digit = ((n % 10) + '0'); n /= ...
C
#include <stdlib.h> #include <string.h> #include <assert.h> #include <stdio.h> #include <zlib.h> #include "rle.h" #include "rope.h" /******************* *** Memory Pool *** *******************/ #define MP_CHUNK_SIZE 0x100000 // 1MB per chunk typedef struct { // memory pool for fast and compact memory allocation (n...
C
/* ============================================================================ Name : clock.c Author : mpelcat Version : 1.0 Copyright : CECILL-C Description : Timing primitive for Preesm Codegen. ============================================================================ */ #include "clock....
C
#include <stdlib.h> #include <stdio.h> #include <math.h> #include "knn.h" #define max(a,b) \ ({ __typeof__ (a) _a = (a); \ __typeof__ (b) _b = (b); \ _a > _b ? _a : _b; }) ////////////////////////////////////// Main Algorithm Functions ////////////////////////////////// // External function called to ...
C
#include<stdio.h> int main (void) { printf ("1. In C, lowercase letters are significant \n"); printf ("2. main is where program execution begins \n"); printf ("3. Opening and closing braces enclose program statements in a routine \n"); printf ("4. All Program Statements must be terminated by a semi-colon \n"); retu...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <stddef.h> #include <stack.h> #include <general_tree.h> #include <baselib.h> struct general_tree *tree_create(void) { struct general_tree *p_tree = NULL; p_tree = malloc(sizeof(struct general_tree)); if (!p_tree) { fprintf(stderr...
C
// 문제 링크 : https://www.acmicpc.net/problem/2580 // 제출 공유 링크 : http://boj.kr/092ef8097e7a4554a801668b62da0d9d // 백준 스도쿠 // c 언어를 공부하기 위해서 풀고 있는 문제 (백트래킹) /* 중간에 정수론 및 조합론이 있었지만, 그것은 정말.. 수학 수식을 공부하고 그대로 코딩하는 방식이라서 코테와는 거리가 멀어 생략하였다. 전역변수로 옮길지 말지 고민하다가 몇몇만 전역변수가 되어버렸다; 예전에는 못 풀었는데.. 어쩌다보니 풀었다; 이전에 너무 어렵게 생각했었나..? 오늘은 ...
C
#include <stdio.h> int *fun() { int a; return &a; } int main() { int *p = NULL; p = fun(); *p = 100; printf("*p=%p\n", *p); return 0; }
C
/* *********************************************************************** */ /* *********************************************************************** */ /* MFILE Memory-mapped I/O Library Source Code Module */ /* *********************************************************************** */ /* File Name : %M...
C
#include <stdio.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <stdlib.h> #define MAX_LINE 80 /* 80 chars per line, per command, should be enough. */ /* The setup function below will not return any value, but it will just: read in the next command line; separate it into distinct arguments (usin...
C
#include <errno.h> #include <math.h> /* C99's isnan() is a macro */ #include <stdlib.h> #include <string.h> #include "private.h" __PUBLIC const char json_true[] = "true"; __PUBLIC const char json_false[] = "false"; __PUBLIC int json_as_bool(const char *json) { if (!json) { errno = EINVAL; return 0; } skip_w...
C
#include "io.h" char rom[ROM_SIZE + 1]; unsigned int p = 0; char io_readChar(){ return rom[p++]; } int io_isEoF(){ return p >= ROM_SIZE; } void io_readRom(){ FILE *romFile = fopen("roms\\DMG_ROM.bin", "rb"); if(romFile != NULL){ fread(rom, 1, ROM_SIZE, romFile); }else{ printf("fi...
C
#include<iostream> #include<algorithm> #include<string.h> using namespace std; int C,B; int visit[650][200000]; int solve(int t, int b) { int& ret = visit[t][b]; if(ret!=0){ return ret; } int c = C+(t*(t+1))/2; if(c>200000){ ret=1; return -1; } if(b<0||b>200000){ ret=1; //d[t][b]=-1; return -1; } ...
C
/* stringdist - a C library of string distance algorithms with an interface to R. * Copyright (C) 2013 Mark van der Loo * * 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 versio...
C
#ifndef ROFI_MODE_H #define ROFI_MODE_H /** * @defgroup MODE Mode * * The 'object' that makes a mode in rofi. * @{ */ /** * Type of a mode. * Access should be done via mode_* functions. */ typedef struct rofi_mode Mode; /** * Enum used to sum the possible states of ROFI. */ typedef enum { /** Exit. */...
C
#include<stdio.h> #include<stdlib.h> #include<glob.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <string.h> #include<errno.h> #include<pwd.h> #if 0 // debug #define DBG(...) printf(__VA_ARGS__) #else #define DBG(...) #endif #if 0 struct passwd { char *pw_name; /* username */...
C
#include "iostream" #include "fstream" #include "math.h" using namespace std; float a = 1/(2*pow(2,0.5)); float dt = 0.006; float t = 3000.0; int n = 10000; float q1[n], q2[n], p1[n], p2[n]; float q1rk[4], q2rk[4], p1rk[4], p2rk[4]; float q1[0] = a, q2[0] = -a, p1[0] = 0.0, p2[0] = 0.0; float e = 1.0/1000; float so...
C
Assignment name : print_hex Expected files : print_hex.c Allowed functions: write -------------------------------------------------------------------------------- Write a program that takes a positive (or zero) number expressed in base 10, and displays it in base 16 (lowercase letters) followed by a newline. If th...
C
void print_char(char); void print_last_digit(int n) { n=n%10; /*obtain last digit*/ if (n<0){ n=n*(-1); /*make pos if neg*/ } print_char(n+48); }
C
/* * Copyright (C) 2012 Sistemas Operativos - UTN FRBA. All rights reserved. * * 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 3 of the License, or * (at your option) any la...
C
/* * Copyright (c) 2008 Rainer Clasen * * This program is free software; you can redistribute it and/or modify * it under the terms described in the file LICENSE included in this * distribution. * */ #include <stdlib.h> #include <stdarg.h> #include <string.h> #include <stdio.h> #include <errno.h> #include "pro...
C
#include<stdio.h> #include<string.h> int main() { char s[70]; int i, j, temp; printf("Enter a string\n"); scanf("%s", s); i = 0; j = strlen(s) - 1; while(i < j) { temp = s[i]; s[i] = s[j]; s[j] = temp; i++; j--; } printf("%s", s); retu...
C
#include "csapp.h" #define MAXARGS 128 void eval(char *cmdline); int parseline(char *buf, char **argv); int builtin_command(char **argv); /* Still runs in main process! */ int builtin_command(char **argv) { if (!strcmp(argv[0], "quit")) exit(0); // Terminate shell's main process! if (!strcmp(argv[0], "&")) retu...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <pthread.h> #include <sys/socket.h> #include <arpa/inet.h> struct Client { struct sockaddr_in clientAddr; int index; int sockID; int len; } clients[1024]; struct Ristoranti { int index; int menu; // indica il cliente che ha ...
C
/* Prime numbers can also be generated by an algorithm known as the Sieve of Erastosthenes. Write a program that implements this algorithm. have the program find all prime numbers up to n = 150. What can you say about this algorithm as compared to the ones used in the text for calculating prime numbers? */...
C
#include <stdlib.h> #include <ctype.h> #include "zw_usbpipe_util.h" static const char* g_arrMsgType[2] = { "Msg-Request", "Msg-Response" }; const char* getMsgTypeName(E_MSG_TYPE e) { return g_arrMsgType[e]; } static const char g_module_name[] = "usbpipe"; static unsigned verbosity = 7; static char* getFi...
C
/*9.3.Se sabe que como máximo en una comisión de Elementos de Programación hay 80 alumnos. De cada alumno se conoce: •Número de DNI (entero). •Apellido y Nombre(80 caracteres). •Nota1, Nota2 (entero). •Nota Promedio (real, calculado según Nota1 y Nota2). Se solicita: a.Declarar un tipo de dato que conte...
C
#include <stdio.h> #include <stdlib.h> int main(void) { int character; while((character = getc(stdin)) != EOF) // get typed(stdin) charcter until the end of line(ctrl D) if(putc(character, stdout) == EOF){ // print the character to terminal fprintf(stderr, "standard output error\n"); // error or end of the fi...
C
#include <stdio.h> #include <stdlib.h> int test[100]; int num = 0, len = 0; void Quick_Core(int arr[], int start, int end) { int left, right, temp, mid; if (start > end) { return; } mid = arr[start]; left = start; right = end; while (left != right) { while (arr[right]...
C
//program listing of data-str\array2.c //Programs on arrays => To demonstrate the fill up logic of an array. /* col -> 1 2 3 4 ------------- row 1| 1 5 9 13 2| 2 6 10 14 => (col-1)*4 + row ^ 3| 3 7 11 15 | 4| 4 8 12 16 */ #include <stdio.h> #include <conio.h> void main(void) ...
C
#include "mylist.h" #include <stdio.h> #include <stdlib.h> int main(){ MYLIST_HEADER *root=createmyList(); int data = 1; int* ptr = NULL; FILE* fp = fopen("list.dat", "w"); ptr = (int*) (insertFirst(root,&data))->Data; printf("%i\n",*ptr); data = data+1; ptr = (int*) (insertLast(root,&data))->Data; prin...
C
#include <stdarg.h> #include <stdio.h> /** * print_strings - print strings * @separator: separator * @n: number of element **/ void print_strings(const char *separator, const unsigned int n, ...) { unsigned int i = 0; va_list args; char *c; va_start(args, n); while (i < n) { c = va_arg(args, char *); if (...
C
#include "hospital.h" #include "comm.h" #include "reparto.h" #ifdef PRINT_COLOR #define REPARTO_NAME ANSI_COLOR_CYAN "Reparto" ANSI_COLOR_RESET #else #define REPARTO_NAME "Reparto" #endif void reparto(char* fifoPathTriage, int IDReparto, int semIDPazienti){ //printf("REPARTO %d AVVIATO\n", IDReparto); printf("["R...
C
/* code for linked lists */ #include "definitions.h" #include "functions.h" #define SYMBOL_ROW ((symbolTableRow*)newLine->data) #define DATA_ROW ((dataTableRow*)newLine->data) #define CODE_ROW ((codeTableRow*)newLine->data) #define ERROR {numOfErrors++; fprintf(stderr, "ERROR: can not allocate memmory.\n");...
C
/* UDP echo server program -- echo-server-udp.c */ #include <stdio.h> /* standard C i/o facilities */ #include <stdlib.h> /* needed for atoi() */ #include <unistd.h> /* defines STDIN_FILENO, system calls,etc */ #include <sys/types.h> /* system data type definitions */ #include <sys/socket.h> /* socket sp...
C
#include <stdio.h> #include <string.h> #include <netdb.h> #include <sys/socket.h> #include <unistd.h> #include<stdlib.h> #define buflen 512 unsigned int portno = 5055; char hostname[] = "192.168.30.6"; char *buf[buflen]; /* declare global to avoid stack */ void dia(char *sz) { printf("Dia %s\n", sz); } int prin...
C
#ifndef CMM_H #define CMM_H // [[Rcpp::depends(RcppArmadillo)]] #include <RcppArmadillo.h> // [[Rcpp::export]] arma::mat r_cmm_internal(unsigned int n, unsigned int m, const arma::vec& p, double nu, unsigned int burn, unsigned int thin, const arma::vec& x_init, unsigned int report_period); //' @name cmm //' @expor...
C
#include <stdio.h> int main(void){ int numero, i; printf("Neste exercício vamos buscar o maior e o menor número em uma lista\nPara isso você escolherá quantos números digitará e depois pressionará ENTER: "); scanf("%d", &numero); int lista[numero+2]; for (i=1; i<=numero; i++){ printf("\nDigite ...
C
#include<stdio.h> #define WIDTH 200 #define HEIGHT 150 int main() { printf("%s = %d\n", "ANCHO", WIDTH); return 0; }
C
#include "hash_tables.h" /** * key_index - gives the index of a key * @key: they key * @size: size of the array of the hash table * Return: index at the key/value pair **/ unsigned long int key_index(const unsigned char *key, unsigned long int size) { unsigned long int kv_index; kv_index = hash_djb2(key); kv_...
C
//program to find and print permutation of any string //swap, permutate , swap (easy but logical program) // C program to print all permutations with duplicates allowed #include <stdio.h> #include <string.h> /* Function to swap values at two pointers */ void swap(char *x, char *y) { char temp; temp = *x; ...
C
//---------------------------------------------------------------------------| SEL von Dietmar SCHRAUSSER 2009 // #include <stdio.h> #include <stdlib.h> #include <string.h> #include <conio.h> #include <time.h> void _profil(); void _kopf(); void main(int argc, char *argv[]) { FILE ...
C
#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include "bitstring.h" #include "huffman.h" void compress(const char *src_filename, const char *dest_filename) { FILE *f_src = fopen(src_filename, "rb"); if (f_src == NULL) { fprintf(stderr, "failed to open %s\n", src_fi...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* libui_pixel_draw.c :+: :+: :+: ...
C
/* Program 2 : Write a Program to print cube of first n numbers . */ extern int printf (const char *, ...); extern int scanf (const char *, ...); void main (void) { int x; printf ("\nEnter a Number :"); scanf ("%d", &x); printf ("\nCube of First %d numbers are : \n", x); for (int i...
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 dias, segundos; printf("digite os dias:"); scanf("%d",&dias); segundos= dias*24*60*60; printf("dias em segundos e %d", s...
C
#include <stdio.h> int main() { int a, b, q, k = 1; scanf("%d %d", &a, &b); int bear[a][b]; for (int i = 0; i < a; i++) { q = k; for (int j = 0; j < b; j++) { bear[i][j] = q; printf("%3d ", bear[i][j]); q = q + a; } k++; printf("\n"); } } }
C
/* * Struct to define a single layer in a NN */ #ifndef LAYER_H #define LAYER_H #include <stdlib.h> #include <stdio.h> #include <math.h> typedef struct Layer { double bias; // bias of the current layer double** weights; // 2D array of random weights int n_neurons; // number of output neurons } Layer; ...
C
#ifndef COPY_H #define COPY_H #include <unistd.h> #include <string.h> #include <sys/mman.h> #include <fcntl.h> #include <syslog.h> #include "conf.h" /** \brief odpowiada za kopiowanie plików z katalogu źródłowego do docelowego \details otwierany jest katalog źródłowy, następnie za pomocą struktury 'dirent' czytany j...
C
#include <stdio.h> #include <string.h> #include <unistd.h> char *my_revstr( char * str ) { char *dest=str; char* p = str + strlen(str)-1; char temp; while(str<p) { temp=*p; *p--=*str; *str++=temp; } str=dest; return str; } void my_putchar(char *s) { write(1,...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* get_fraction.c :+: :+: :+: ...
C
#include <stdlib.h> #include <unistd.h> #include <string.h> #include <stdio.h> char * convert(char * s, int numRows){ char **stock = malloc(sizeof(char*)*numRows); char *ret = malloc(sizeof(char)*strlen(s)); for(int i= 0; i < numRows; i++) { char* tmp = malloc(sizeof(char)*strlen(s)); memset(tmp, 0, strl...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> typedef struct StructTree{ int Key; struct StructTree *Left; struct StructTree *Right; struct StructTree *Back; } TypeTree; int StringCmp(int *TempInt1,int *TempInt2,char filename[]); void FreeTree(TypeTree *Tree); TypeTree *AddTree(TypeTree *Tre...
C
#include<stdlib.h> #include<stdio.h> #include<math.h> #include "Point.h" #define POW(a) (a)*(a) static void Point_Init(Point*); static float get_abscisse(Point *This); static int set_abscisse(Point *This,float abscisse); static float get_ordonne(Point *This); static int set_ordonne(Point *This,float ordonne); sta...
C
#include <sys/types.h> /* some systems still require this */ #include <sys/stat.h> #include <stdio.h> /* for convenience */ #include <stdlib.h> /* for convenience */ #include <stddef.h> /* for offsetof */ #include <string.h> /* for convenience */ #include <unist...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* read_cor.c :+: :+: :+: ...
C
//DATAPOINTS //Calcula quadrado e raz quadrada de nmeros introduzidos pelo utilizador em estruturas de dados //BIBLIOTECAS #include <stdio.h> #include <math.h> #include <windows.h> //ESTRUTURAS DE DADOS typedef struct DPs { int num; int quadrado; float raiz; }DP; //PROTTIPOS int menu(void); int inseri...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* check_error_utils.c :+: :+: :+: ...
C
/** \brief This is a standalone test program for testing the hybrid ARQ concept \author Thomas Watteyne <watteyne@eecs.berkeley.edu>, September 2010 */ //board #include "gina.h" //drivers #include "leds.h" #include "button.h" //openwsn #include "opendefs.h" #include "scheduler.h" #include "packetfunctio...
C
/* * Header file for a generic fixed capacity queue implemented with an array * */ #ifndef _ARRAY_QUEUE_H_ #define _ARRAY_QUEUE_H_ typedef void (*FreeFunction)(void*); /** * ptr_array: circular array of pointers to the struct's contents * elem_size: the size of the elements in the queue * length: the current...
C
// ------------------------------------------------------------------ // exemple-serie.c // Fichier d'exemple du livre "Developpement Systeme sous Linux" // (C) 2000-2019 - Christophe BLAESS <christophe@blaess.fr> // https://www.blaess.fr/christophe/ // ------------------------------------------------------------------...
C
/* ______ _________ _ _ _ | ____ \|___ ___| | | | | | | | \ \ | | | |____| | | | | | | | | | | ____ | | | | |____/ /___| |___| | | |_____| | |_______/|_________|_| |_________| M A H I R L A B I B D I H A N */ int main() { // for(;condition;) // { // }...
C
#include "holberton.h" /** * rot13 - encodes a string using rot13 * @s: string being encoded * * Return: returns a string encoded in rot13 */ char *rot13(char *s) { int x, y; char *reg = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; char *rot = "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM";...
C
#include "ft_ls.h" char *ft_get_right(size_t n) { char *s; if(!(s = ft_strnew(10))) exit (0); s[0] = (S_IRUSR & n) ? 'r' : '-'; s[1] = (S_IWUSR & n) ? 'w' : '-'; s[2] = (S_IXUSR & n) ? 'x' : '-'; s[3] = (S_IRGRP & n) ? 'r' : '-'; s[4] = (S_IWGRP & n) ? 'w' : '-'; s[5] = (S_IXGRP & n) ? 'x' : '-'; s[6] = (...
C
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <assert.h> //#include <iostream> //using namespace std; int BinarySearch(int* a, int n, int x) { assert(a); int begin = 0; int end = n - 1; while (begin <= end) { int mid = begin + ((end - begin) >> 1); ...
C
#include<stdio.h> #include<stdlib.h> #include<GL/glut.h> #include<math.h> GLint screenSize[2] = {800, 500}; // width, height struct polygonPoints { GLint x1, y1, x2, y2, x3, y3, x4, y4; }; struct polygonPoints *skyPolygon, * outerskyPolygon, *oceanPolygon, *ozonePolygon, *landPolygon, *greenPolygon; // background str...
C
/* Labs week 4 Erik Grunnr Problem 4 */ #include <stdio.h> int main () { int input1=0; int input2=0; int calc1=0; int calc2=0; printf("pls input two integers\n"); scanf("%d",&input1); scanf("%d",&input2); flushall(); calc1 = input1%input2; switch (calc1)//switch stateme...
C
/** * \file reader_t1_block.c * \copyright This file is part of the Open-ISO7816-Stack project and is distributed under the MIT license. See LICENSE file in the root directory. * This file contains the functions to operate safely on the READER_T1_Block data stuctures representing the T=1 Block objects. */ #inclu...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <pthread.h> #include "types.h" #include <sys/queue.h> #include "queue.c" TicketCaller* pc; pthread_mutex_t mutex_cliente; pthread_mutex_t mutex_retrieved_ticket; pthread_mutex_t mutex_queue; sem_t sem_espera_cliente; sem_t* sem_client...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/wait.h> #include <sys/stat.h> #include <fcntl.h> #include <signal.h> #include "cmdline.h" #define BUFLEN 1024 #define OK 0 #define KO 1 /** * Test a command line "str" * * This function is static...
C
#include <stdio.h> #include <stdlib.h> typedef struct Node Node; typedef struct Node { int data; Node* Node; }Node; void addNode(Node* head, int data); void DelNode(Node* head); int main() { int N; scanf("%d", &N); if (N == 1) { printf("0"); return 0; } int j; Node* head1 = (Node*)malloc(sizeof(No...
C
#include <stdio.h> int a=22; void print(){ a=2; printf("a is %i\n",a); } void print1() { a=9; printf("a is %i\n",a); } int main() { int c; printf("i is%i\n",c); print(); print1(); return 0; }
C
#include <unittests.h> #include <pb_encode.h> #include "short_array.pb.h" int main() { int status = 0; COMMENT("Test message length calculation for short arrays"); { uint8_t buffer[TestMessage_size] = {0}; pb_ostream_t ostream = pb_ostream_from_buffer(buffer, TestMessage_size); ...
C
#include<stdio.h> #include<stdlib.h> void traversei (int arr[],int len); void traversei (int arr[],int len){ for(int i=0;i<len;i++) { printf("%d ",arr[i]); } }
C
#include <stdio.h> #include <stdlib.h> // on_exit static void exit_handler(int status, void *arg) { printf("exit status: %d, arg: %s\n", status, (char *)arg); } // atexit static void exit_handler2() { printf("exit_handler2()\n"); } // atexit static void exit_handler3() { printf("exit_handler3()\n"); } int main()...
C
/* $Id$ */ /* This file contains the expression evaluator. It exports the following routines: - int eval_cond(p_tree p) This routine evaluates the conditional expression indicated by p and returns 1 if it evaluates to TRUE, or 0 if it could not be evaluated for some reason or if it evalutes to FALSE. If the ...
C
/* * CS362 Software Engineering II * Summer 2019 * * Daniel S Wagner * wagndani@oregonstate.edu * * Assignment 3 * * unittest4.c * Testing the refactored tribute case function */ // STANDARD C LIBRAIRIES #include <string.h> #include <stdio.h> #include <assert.h> #include <stdlib.h> // SPECIFIC DOMINION...
C
#include <stdio.h> #include <string.h> int main() { char str[] = "!looc os si 2103AD"; int n = strlen(str); for (int i = 0; i<=n-1; i++) { printf("%c", str[n-i] ); } printf("\n"); return 0; }
C
#include "monty.h" /** * op_sub - subtracts the values from the top two elements of the stack * @head: double pointer to head node * @line_number: line number being intrepreted from Monty file */ void op_sub(stack_t **head, unsigned int line_number) { int first, second; if (!head || !*head || !(*head)->next) ...
C
#include <stdio.h> #include <stdlib.h> typedef struct _node{ int data; struct _node *next; } node; typedef struct _stack{ node* top; node* end; } stack; void stackPrint( stack* s){ node* n; if(NULL != s && NULL != s->top) n= s->top; while( NULL != n){ printf("%d ",n->data)...
C
#include <stdio.h> #include <math.h> int f(double n,double c,double t) { if(c*n*(log(n)/log(2.0))<=t)return 1; return 0; } int main() { int c,t; scanf("%d%d",&c,&t ); double low=0,high=t,n=0; while(low<high) { double n=(high+low)/2; if(f(n,c,t)==1) low=n; else high=ceil(n-1); // for red...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* process_command.c :+: :+: :+: ...
C
#include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <stdio.h> #include <string.h> int main(int argc, char** argv) { int bytesWritten = 0; int i = 15; int f = open("myfifo", O_WRONLY | O_APPEND | O_NONBLOCK); if (f < 0) { perror("Cannot open"); return 1; } else fprintf(s...
C
#include <stdlib.h> #include <stdio.h> int main( int argc, char **argv ) { int v; int array[1024]; int i = 0; while ( scanf("%d", &v) != EOF ) { array[i++] = v; if ( i > 1023 ) break; } print_array( array, i ); printf( "------------\n" ); quicksort( array, i ); pr...
C
#define _CRT_SECURE_NO_WARNINGS 1 #pragma warning(disable:6031) #include "List.h" //ڵ㴴 ListNode* BuyListNode(LTDateType x) { ListNode* node = (ListNode*)malloc(sizeof(ListNode)); if (node == NULL) { printf("ٽڵʧܣ"); exit(-1); } node->next = NULL; node->prev = NULL; node->date = x; return node; } //β庯 ...
C
#include<stdio.h> unsigned long rand0(void); void seed(void); long count[10]; int main(void) { for(int i=0;i<10;i++)count[i]=0; printf("%5d%5d%5d%5d%5d%5d%5d%5d%5d%5d\n",1,2,3,4,5,6,7,8,9,10); for(int i=0;i<10;i++) { rand0(); for(int i=0;i<10;i++) { printf("%5ld",count[i]); } printf("\n"); seed...
C
#include <stdio.h> int main(){ printf("Enter a floating point number : "); float f; scanf("%f", &f); printf("%d \n%d \n%d", (int)f%10, (int)f%100, (int)f); return f; }
C
#include <stdio.h> #include <stdlib.h> #include <conio.h> //#define clrscr() system("clear") //#define getch() system("echo ") int* cargar(int* U,int* conj); void menup (); void menuop (); void imprimir(int * conj); void uni(int * conj1, int * conj2); void impe(int * conj); void card(int * conj); void inter(int *r, in...
C
#include<stdio.h> int main(){ int a = 0; float b = 0.0f; scanf("%d%f",&a,&b); printf("a=%d\n",a); printf("b=%f\n",b); return 0; }
C
#include <math.h> #include <stdio.h> #include <stdlib.h> #include "tpool.h" #define PRECISION 100 /* upper bound in BPP sum */ /* Use Bailey–Borwein–Plouffe formula to approximate PI */ static void *bpp(void *arg) { int k = *(int *) arg; double sum = (4.0 / (8 * k + 1)) - (2.0 / (8 * k + 4)) - ...
C
#define _CRT_SECURE_NO_WARNINGS 1 //static ξֲ //1 //ֲӰ //#include <stdio.h> //void test() //{ // int i = 0; // i++; // printf("%d", i); // //} //int main() //{ // // for (int i = 0; i < 10; i++) // { // test(); // } // system("pause"); //} // 2 // static ξֲ ı˱ڣ̬Ȼ // ֱ //#include <stdio.h> //void test() //{ // //...
C
//ǽ 5-1 factorial /* #include<stdio.h> int factorial(int n) { if (n > 0) return n * factorial(n - 1); else return 1; } int main() { int x; printf(" Էϼ : "); scanf("%d", &x); printf("%d %dԴϴ.\n", x, factorial(x)); return 0; } */ //ǽ 5-2 Euclidean method of mutual division /* #include<stdio.h> int gcd...
C
#include "pieces.h" void initChessBoard() { for (int i = 0; i < 8; i += 2) { for (int j = 0; j < 8; j += 2) //def chessboard { board[i][j] = white; board[i][j + 1] = black; board[i + 1][j] = black; board[i + 1][j + 1] = white; } } for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) ...