language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <errno.h>
const int kMessageSize = 10240;
void send_data(int sockfd) {
char* query;
query = malloc(kMessageSize+1);
for(int i = 0; i < kMessageSize; ++i) query[i] = 'a';
query[kMessageSi... |
C |
#define CASE 50
struct slider {
int L, H; //Largeur et hauteur de la grille
int x_slider, y_slider; //Position du slider
int x_exit, y_exit; //Position de la sortie
int N; //Nombre de murs
int wall[20][20]; //Position des murs en forme de matrice
int x; //Position x d'un mur
int y; //P... |
C | #include <stdio.h>
#include <math.h>
#include "pvm3.h"
#define RAND_MAX 2147483647
int calculoPI(int tid,int numiter) {
double x,y;
int cont=0,i;
srand(tid+1);
for(i=0;i<numiter;i++){
x=((double)rand())/((double)RAND_MAX);
y=((double)rand())/((double)RAND_MAX);
if((x*x+y*y)<=1) cont++;
}
return(cont);
}... |
C | #include "hash_table.h"
int main(int argc, char* argv[])
{
struct hash_table_t* table = hash_table_initialize(100);
if (table)
printf ("Success!\n");
else
printf ("Fail!\n");
return 0;
}
|
C | #include<stdio.h>
void cal(int p,int q,int n,long long *result){
int i;
long long t,m;
long long foo,bar;
if(n==0) *result=2;
else if(n==1) *result=p;
else if(n%2==0){
t=(cal(p,q,n/2,&foo),foo),m=1;
for(i=0;i<n/2;i++)
m*=q;
*result=t*t-2*m;
}else
*result=(cal(p,q,n-1,&foo),foo)*p-(cal(p,q,n-2,&bar),ba... |
C | #include<stdio.h>
#include<wiringPi.h>
#define buttonPin 1 //define Button pin
#define ledPin 0 //define LED pin
int main(void)
{
if(wiringPiSetup() == -1) //wiringPi initialize failed
{
printf("WiringPi Initialize failed \n");
return 1;
}
pinMode(ledPin, OUTPUT);
pinMode(butto... |
C | #include<stdio.h>
void main()
{
printf("Program to print even numbers lying between 1 and 100.\n\n");
int i;
printf("Even numbers lying between 1 to 100 are:\n");
for(i=1;i<=100;i++)
{
if(i%2==0) //since if any integer leaves remainder 0 on division with 2 is even.
printf("%d ",i);
}
getch();
... |
C | #include "dbl.h"
int db_open(const char *path, sqlite3 **db) {
char q[LINE_SIZE * 2];
snprintf(q, sizeof q, "file://%s", path);
int rc = sqlite3_open_v2(path, db, SQLITE_OPEN_READWRITE, NULL);
if (rc != SQLITE_OK) {
#ifdef MODE_DEBUG
fprintf(stderr, "db_open: path: %s, status: %d, message: %s\n"... |
C | /*
Name of file : functions.c
Author : Christian Janeczek <cjaneczek@tgm.ac.at>
Version : 2014-10-01
Description : Completing functions prototypes
*/
#include "functions.h"
/*
* Taking the following state
*/
State nextState(State s){
switch(s){
case GREEN:
s = BLINKING_GREEN;
break;
case BL... |
C | #include "parser.h"
bool trimNewLine(char* str)
{
uint length = strlen(str);
if (str[length - 1] != '\n') return false;
str[length - 1] = '\0';
return true;
}
Asm parse(const str s)
{
// Результат разбора строки ассемблера.
Asm res = {"", "", "", ""};
// Длина строки.
int length = strlen(s.chars);
// Текущ... |
C | #include "holberton.h"
/**
* print_line - prints n times '_'
* @n: the times fot 'n? to print
* Return: always 0
*/
void print_line(int n)
{
int a;
for (a = n; a > 0; a--)
{
_putchar('_');
}
_putchar('\n');
}
|
C | #include <stdio.h>
int main()
{
int num, max, min;
scanf("%d", &num) ;
max = num ;
min = num ;
while (num != -1)
{
scanf("%d", &num) ;
if (num == -1)
break ;
if (num > max)
max = num ;
if (num < min)
min = num ;
... |
C | #ifndef __CMDOPT_H__
#define __CMDOPT_H__
/* One-letter command line option processing. */
/* ANSI C, IRIX 5.2, 4. Apr. 1995. Andris */
/* ---- STANDARD HEADERS ---- */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
/* ---- PROTOTYPES ---- */
#ifdef __cplusplus
extern "C" {
#endif
... |
C |
//Busca el padre de 'nodo'
nodo_abb_t* buscar_padre(abb_t* arbol,nodo_abb_t* raiz, nodo_abb_t* nodo){
nodo_abb_t *nodo_anterior;
nodo_abb_t *nodo_actual = raiz;
int comparacion = arbol->comparar_clave(nodo_actual->clave, nodo->clave);
while(comparacion != 0){
nodo_anterior = nodo_actual;
if(comparacion < 0){
... |
C | #include<stdio.h>
int main()
{
int a,b,c;//greater integer among 3
printf("Enter the first Integer ");
scanf("%d",&a);
printf("Enter the second Integer ");
scanf("%d",&b);
printf("Enter the third Integer ");
scanf("%d",&c);
if(a>b){
if(b>c||c>b)
printf("Quanti... |
C | #include <stdio.h>
#include <stdlib.h>
#include "funciones.h"
#define T 5
/**
system("clear");
system("read -p 'Press Enter to continue...' var");
*/
/// SILLAS DEL AULA
int main()
{
int arraySillas[T];
int maximo;
int minimo;
int ocupadas;
int libres;
int primerIndice;
///inicia... |
C | #include <stdio.h>
#include <string.h>
#define MAX_N 50
#define MAX_M 100
int calculate_inversion(char *dna, int len);
void bubble_sort_dna(int lower, int higher);
void swap_dna(int idx_1, int idx_2);
char dnas[MAX_M][MAX_N + 1];
int n, m;
char *dna_ptrs[MAX_M] = {};
int dna_inversions[MAX_M] = {};
int main(int ar... |
C | #ifndef UTKERESO_H
#define UTKERESO_H
#include <stdbool.h>
#include "labirintus.h"
#include "karakter.h"
bool utkereso(Labirintus lab, Karakter karakter) {
// & karakterek jelölik a bejárt útvonalat (vizuálisabb + nincs végtelen ciklus)
if (lab[karakter.x][karakter.y] == LAB_FAL || lab[karakter.x][karakter... |
C | #include <stdio.h>
#include <stdlib.h>
#include "menu.h"
#include "action.h"
#include "donnees.h"
void firstMenu()
{
int n =0;
printf("MENU:\n");
printf("Which action do you want to make?\n ");
printf("1 - Display all data in order\n");
printf("2 - Display all data in ascending order\n");
print... |
C | #ifndef _ATOMIC_H_
#define _ATOMIC_H_
#include <stdint.h>
#define ANDROID_ATOMIC_INLINE inline __attribute__((always_inline))
extern ANDROID_ATOMIC_INLINE void android_compiler_barrier(void)
{
__asm__ __volatile__ ("" : : : "memory");
}
extern ANDROID_ATOMIC_INLINE void android_memory_barrier(void)
{
__asm_... |
C | #include<stdio.h>
main()
{
int month,day,x;
scanf("%d%d",&month,&day);
x=(month<day)?199:200;
printf("value of x is=%d",x);
}
|
C |
#include <stdbool.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Initialize the values of the battery resource.
*
* The battery resource is exposed via Nexus Channel, in the following manner:
*
* * GET requests are unsecured - any device may GET the current battery state
* * POST requests are ... |
C | /*
Alocao Esttica X Dinmica
A alocao esttica ocorre em tempo de compilao, ou seja, no momento
em que se deine uma varivel ou estrutura necessrio que se deinam seu tipo
e tamanho. Nesse tipo de alocao, ao se colocar o programa em execuo, a
memria necessria para utilizar as variveis e estruturas estticas precis... |
C | #include <stdio.h>
#include <string.h>
void filter_invalid_character (char *in, char *out)
{
}
void strrpl (char *in, char *out, const char *src, const char *dst)
{
if (in == NULL || out == NULL || src == NULL || dst == NULL)
{
return;
}
if (strcmp (in, "") == 0 || strcmp (src, "") == 0)
... |
C | #include <stdio.h>
#include <limits.h>
#include "util.h"
int* plusOne(int* digits, int digitsSize, int* returnSize){
*returnSize = digitsSize+1;
int *ret = (int*)malloc(*returnSize*sizeof(int));
int tail = digitsSize;
int flag = 1;
for (int i = digitsSize - 1; i >= 0; i--) {
int n = flag + ... |
C | #include <stdio.h>
#include <string.h>
int main ()
{
int arr[100000], i, sum, n, ans, avg, num=1;
while (scanf("%d", &n)==1)
{
if (n==0)
break;
else
{
sum=0;
ans=0;
for (i=0; i<n; i++)
{
scanf("%d", &arr[i]);... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* Written by Marcel Goh on 19 February 2018. This program takes two command line arguments, a major scale
* and a solfege value (Do, Re, Mi, etc.). The program will then print out the note that corresponds to the
* solfege in the scale.
* (Adapted from... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_get_coords.c :+: :+: :+: ... |
C | /**
* Gedare Bloom
* syscall.c
*
* Implementation of the system calls
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include "memory.h"
#include "cpu.h"
typedef struct
{
char letter1;
char letter2;
char letter3;
char letter4;
}hexChars;
hexChars getAllLetters(hexChars myLetters, uint32_t hexNum)... |
C | #include <stdio.h>
#include <cs50.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
//The numbers used for translation from ASCII to alphabetical
#define UPPER 65
#define LOWER 97
int main(int argc, string argv[])
{
// Check that argument k has been entered correctly
if(argc != 2)
{
p... |
C | #include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include "heap.h"
minHeap initMinHeap(int size) {
minHeap hp ;
hp.size = size ;
return hp ;
}
void swap(node *n1, node *n2) {
node temp = *n1 ;
*n1 = *n2 ;
*n2 = temp ;
}
void bubbleUp(minHeap *hp, int i) {
if(i <= 0) retur... |
C | /*
Geral:
Código feito e testado no Slackware 14.1 com gcc 4.8.3 e bash 4.3
Escrito(e muito mal escrito) por Eduardo Mendes (mendesxeduardo@gmail.com)
É um passo a passo desenvolvido nos laboratórios da Fatec-AM
Durante as aulas de criptografia
Esse texto é melhor visualizado no gedit(http://www.gedit.org)... |
C | #include "lib.h"
#ifdef linux
int8_t toggle = FALSE;
int count = 5;
struct aiocb cb;
char buffer[256];
void* thread_write(void* args)
{
int cat_file = open("concatenated", O_CREAT | O_APPEND | O_WRONLY, 0644);
if (cat_file == -1)
{
perror("open");
exit(EXIT_FAILURE);
}
while (count > 0)
{
while (FALSE == t... |
C | #include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <errno.h>
#include <stdlib.h>
#include "pthread.h"
#include <stddef.h>
#include <pulse/simple.h>
#include <pulse/error.h>
#ifdef HAVE_CONF... |
C | /******************************************************************************/
/** @file systick.c
*******************************************************************************
*
* @brief General systick module for stm32l0
* <p>
* Allows to generate delays in busy loop
*
... |
C | #include <stdio.h>
#define MAX 100
int main(){
char frase1[MAX], frase2[MAX];
int vocales1=0,vocales2=0;
printf("Frase 1:\n");
gets(frase1);
printf("Frase 2:\n");
gets(frase2);
vocales1 = vocal(frase1);
vocales2 = vocal(frase2);
if (vocales1>vocales2)
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "wasm.h"
#define own
const int iterations = 100000;
int live_count = 0;
void finalize(void* data) {
intptr_t i = (intptr_t)data;
if (i % (iterations / 10) == 0) printf("Finalizing #%" PRIdPTR "...\n", i);
--live_count;
... |
C | //
// main.c
// T4E1
//
// Created by Abraham Esses on 3/30/16.
// Copyright © 2016 Abraham Esses. All rights reserved.
//
//----------------------------------------------Instrucciones-------------------------
// Dado el siguiente problema:
// Blancanieves y los siete enanitos viven en una casa donde solo existen ... |
C | #include "line_trace.h"
float e = 0;
float p = 0;
float i = 0;
float d = 0;
//カラー値よりTurnの値を決定する
void line_trace(float color_value, int *turn)
{
//変数の宣言
static float integral = 0, differential = 0, e_last = 0;
//偏差eを更新
e_last = e;
//偏差e =(目標値)ー(現在時間tの取得値)
e = DESIRED_VALUE - color_value;
//積分値
integral += (... |
C | #include "queue.h"
void queue_init(Queue *queue) {
queue->enqueue = enqueue;
queue->dequeue = dequeue;
queue->head = NULL;
queue->tail = NULL;
}
int enqueue(Queue *queue, void *item) {
int status = UNDEFINED;
if (queue) {
Node *node = (Node *) malloc(sizeof(Node));
node->item =... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* get_next_line_bonus.h :+: :+: :+: ... |
C | #include <stdio.h>
#include "fsm.h"
#include "state_one.h"
static state_t actual_state;
static state_t next_state;
static hook start_hook = NULL;
static hook during_hook = NULL;
static hook stop_hook = NULL;
void fsm_init(void)
{
actual_state = state_one;
actual_state->start();
if( start_hook )
... |
C | #include "BotXO.h"
#include "stdbool.h"
#include "time.h"
#include "stdlib.h"
#include "stdio.h"
bool z=false;
char arr[8];
int vac[8];
int x;
// выбор случайной свободной клетки
// p1 - записываемый символ
// p2 - другой символ
void rand_move(char p1, char p2) {
if (z == false) {
for (int... |
C | // GBA Video Registers and Flags
#define REG_DISPCTL (*(unsigned short *)0x4000000)
#define MODE3 3
#define BG2_ENABLE (1<<10)
// Create a color with the specified RGB values
#define COLOR(r, g, b) ((r) | (g)<<5 | (b)<<10)
// Calculate the position of a pixel based on its row and column
#define OFFSET(r, c, rowlen) (... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memmove.c :+: :+: :+: ... |
C | //#include "type.h"
//#include "defines.h"
/******** message.c file ************/
#define NMBUF 10
struct semaphore nmbuf, mlock;
MBUF mbuf[NMBUF], *mbufList; // mbufs buffers and mbufList
//nmbuf = NMBUF; // number of free mbufs
//struct semaphore PROC.nmsg = 0; // for proc to wait for messages
int menqueue(MBUF **... |
C | /*Ejercicio 1*/
#include <stdio.h>
double Factorial (int);
int main()
{
double fact;
int N;
printf("Ingrese el numero del que requiere el factorial ");
scanf("%d",&N);
fact= Factorial(N);
printf("%lf",fact);
}
double Factorial(int N)
{
double acum;
int i=1;
acum=N;
if(N==0)
{
acu... |
C | #include <stdio.h>
#define max_num (1000000000)
int main()
{
int num[3];
int high, low, tmp;
int i;
while (scanf("%d %d %d", num, num + 1, num + 2) == 3) {
high = 0;
low = 0;
for (i = 0; i < 3; i++) {
while (num[i] > max_num) {
num[i] -= max_num;
high++;
}
while (num[i] < (-max... |
C | /*
Copyright 2020 Andrew Li, Gavin Li
li.andrew.mail@gmail.com
gavinux@gmail.com
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0... |
C | /*
5. Faça um programa que verifique se um número é primo por meio de um função. Ao final
imprima o resultado.
*/
#include<stdio.h>
int main() {
int num;
printf("Digite um numero: ");
scanf("%d", &num);
primo(num);
return 0;
}
void primo(num)
{
int i, resultado = 0;
for (i = 2; i <= num / 2;... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* map_parse.c :+: :+: :+: ... |
C |
#include <stdio.h>
struct ListNode {
int val;
struct ListNode *next;
};
void dump(struct ListNode *head) {
if (head == NULL) { printf("list null! \n"); }
struct ListNode *node = head;
while (node != NULL) {
printf("%d -> ", node->val);
node = node -> next;
}
printf("\n");
... |
C | #include <stdio.h>
int fibbonaci(int x){
int first=0,second=0,current=0,i=0,firstTime=1;
x-=2;
printf("That number in the fibbonacci sequence is");
if(x+2<3){
printf(" 0\n");
return 0;
}
for(i=0;i<x;i++){
if((first==0||second==0)&&firstTime!=0){
current=1;
... |
C | /* Implementations of the item struct */
#include <string.h>
#include "game-state/item.h"
#include "game-state/game_action.h"
#include "cli/util.h"
// BASIC ITEM FUNCTIONS -------------------------------------------------------
/* see common-item.h*/
int item_init(item_t *new_item, char *item_id, char *short_desc,
... |
C | /*
** EPITECH PROJECT, 2018
** connect4
** File description:
** game
*/
#include <stdbool.h>
#include <errno.h>
#include "my.h"
int scan_input(char player)
{
int data = 0;
int nb = 0;
errno = 0;
printf("Player %c, where do you whant to play: ", player);
while (nb != 1) {
nb = scanf("%d", &data);
if (nb == ... |
C | #include<stdio.h>
#include<stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include "proto.h"
#include <unistd.h>
int main(int argc, char const *argv[])
{
int sd;
struct sockaddr_in laddr,saddr;
struct meg_st *mes;
socklen_t saddrlen;
char saddr_c[40];
int size = sizeof(*mes) + NA... |
C | /*
Interprteur de commandes but pdagogique
Copyright (C) 2011-2018 Guillaume Huard
Ce programme est libre, vous pouvez le redistribuer et/ou le modifier selon les
termes de la Licence Publique Gnrale GNU publie par la Free Software
Foundation (version 2 ou bien toute autre version ultrieure choisie par vous).
Ce prog... |
C | #include <stdio.h>
#include "stackD.h"
#include<string.h> //memset
#include<stdlib.h> //memeory allocation
/*Global variable */
int size_ = 0;
int* stack_ = NULL;
int head_ = -1;
//TO-DO need to improve error return with error bit structure
//known issue : if we are passing 0 as data it will false fail
vo... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* la_mult.c :+: :+: :+: ... |
C | #include <stdio.h>
#include "matrice.h"
void printMatrice(ByteMatrice matrice) {
for (int row = 0; row < matrice.rows; row++) {
printf ("| ");
for (int col = 0; col < matrice.columns; col++) {
printf("%c ", matrice.map[row][col]);
}
printf("|\n");
}
} |
C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main (void){
int vetor[5];
int i,cont;
for ( i = 0; i < 5; i++)
{
printf("Digite o %iº número:", i + 1);
scanf("%i", &vetor[i]);
}
for ( i = 0; i < 5; i++)
{
if (vetor[i] > 100)
{
cont+... |
C | #include <stdio.h>
#define SIZE 10
void bubbleSort(int * const array, size_t size);
int main (void)
{
//Initializing array called a
int a[SIZE] = {4, 1, 52, 1, 7, 9, 4, 3 , 3 , 1};
size_t i; //Counter for array
puts("Data in the original order");
for (i = 0; i < SIZE; i++)
{
printf("%4d", a[i]);
}
puts(""... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* lem_in.c :+: :+: :+: ... |
C | #include <stdio.h>
int main()
{
int a[3][3] = {{10, 20, 30}, {40, 50, 60}, {70, 80, 90}};
}
/*
Задачи:
Пусть у нас есть матрица a размера 3 на 3:
10 20 30
40 50 60
70 80 90
1) Напечатате на экран центральный элемент этой матрицы.
... |
C | #include<stdio.h>
main()
{
unsigned int i;
for(i=10;i>=0;i--)
printf("%d",i--);
} |
C | # https://www.facebook.com/permalink.php?story_fbid=180106856999528&id=100050006454252
# subscibe by Aditya Girishkumar
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
struct Queue
{
int front,rear,capacity;
int *ptr;
};
struct Queue* createQueue(int cap)
{
struct Queue *Q;
Q=(struct Queue*)mal... |
C | /************************************************************************
Flint is a FORTRAN checker. It takes FORTRAN code as its input, and
generates warnings about dubious FORTRAN. These messages are written
both to the terminal, and a listing file.
There are some places where better use could have been ma... |
C | #include "trie.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
node* leDicionario()
{
int qtdDic, i, j;
char *palavra;
palavra = (char*)malloc(sizeof(char)*15);
node *root = (node*) malloc(sizeof(node));
root->filho = (node*) malloc(sizeof(node));
node *aux = root->filho;
aux-... |
C | #include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include <string.h>
int tube[2];
void sigusr1_handler(int signum, siginfo_t *info, void* pasUtileIci)
{
printf("Received SIGUSR1 !\n");
char buf[8];
if(read(tube[0], buf, sizeof(size_t)) == -1) {
p... |
C | #ifndef _LIST_H_
#define _LIST_H_
#include <stdbool.h>
typedef struct node{
void *data;
struct node *next;
}node;
typedef struct{
struct node *head;
struct node *tail;
long len;
}List;
extern void list_init(List *list);
extern bool is_empty(List *list);
extern void list_insert(List *list, vo... |
C | #include <sys/ioctl.h>
#include <linux/i2c-dev.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdint.h>
#include <stdio.h>
const uint8_t sonar_address[] = {0x04, 0x06, 0x08, 0x0a};
const char* sonar_i2c_dev = "/dev/i2c-2";
volatile int sonar_fd;
const uint8_t sonar_ping = 0x51;
void initSonar() {
printf("WARNI... |
C | #include "sort.h"
/**
* bubble_sort - sorts an array of integers in ascending order using Bubble
* Sort Algorithm
* @array: array to be sorted
* @size: size of the array
*
* Return: no return for this void function
*/
void bubble_sort(int *array, size_t size)
{
size_t count, finder;
int temp;
if (size < 2)
... |
C |
#include "avr_modules.h"
#if USE_AVR_MATH_MODULE
#if USE_AVR_MATH_SELECT_SORT
void avr_math_select_sort(uint16_t* start, uint16_t* stop) {
if ( start == 0 || stop == 0 ) return;
uint16_t temp;
uint16_t* pcur = start;
uint16_t* pmov = pcur + 1;
do {
if ( *pcur > *pmov ) {
tem... |
C | #include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <libpmemobj.h>
#include "layout.h"
int main(int argc, char *argv[])
{
int p;
struct stat s;
PMEMobjpool *pop;
TOID(struct my_root) root;
TOID(struct rectangle) rect;
if (argc < 2) {
printf("Usage:... |
C | #include <stdio.h>
#include <stdlib.h>
int main()
{
int num = 1;
printf("打印9x9乘法表:\n");
output:for(int row = 1;row <= 9;row++){
for(int line = 1;line <= row;line++){
printf("%d x %d = %d ", line, row, row * line);
}
printf("\n");
}
num++;
if(num == 2){
... |
C | #include "func.h"
void child_handle(int fdr)
{
char flag=1;
int new_fd;
while(1)
{
recv_fd(fdr,&new_fd);//从父进程接收任务
send_data(new_fd); //这里容易产生段错误,当发送、接受速度不匹配时
write(fdr,&flag,sizeof(flag));//通知父进程,完成发送任务
}
}
void make_child(pchild p,int num)
{
int i;
int fds[2];
pid_t pid;
for(i=0;i<num;i++)//创建多个子进程... |
C | # ifndef _CODE_H
# define _CODE_H
# include <stdint.h>
# include <stdbool.h>
/**
* This code is from the assigment PDF
**/
typedef struct code
{
uint8_t bits[32];
uint32_t l;
} code;
static inline code newCode()
{
code t;
for (int i = 0; i < 32; i += 1) { t.bits[i] = 0; }
t.l = 0;
return t;
}
static inlin... |
C | #include "obj.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static char* _create_string(object* obj);
/**
* Virtual method table for object
*/
static struct object_vmt vmt = {
_create_string
};
/**
* Constructor for object
*/
object* object_init(object* self)
{
if(self != NULL) ... |
C | #define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include"LinkList.h"
struct LinkList
{
struct LinkNode header;
int size;
};
struct LinkList *Init_LinkList()
{
struct LinkList *list = (struct LinkList *)calloc(1, sizeof(struct LinkList));
list->header.next = N... |
C | #ifndef HTABLE_H_
#define HTABLE_H_
#include <stdio.h>
#include "container.h"
/**
* Htable header file.
* COSC242 Group Assignment, September 2017.
* @author Daniela Lemow, Megan Seto and Nikolah Pearce.
*/
typedef struct htablerec *htable;
extern void htable_free(htable h);
extern int htable_insert(htable h,... |
C | #include <stdio.h>
#include <sys/socket.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <string.h>
#define PORT 7000
int main(int argc, char *argv[])
{
int index = 0;
struct sockaddr_in address;
int sock_fd;
int val;
struct sockaddr_in serv_addr;
char buffer[1024];
if ((sock_fd =... |
C | #include "../include/escalonador.h"
#include "../include/gerente_execucao.h"
#include <string.h>
#include <time.h>
#include <errno.h>
key_t escalonadorMsqKey = 0x1123; /**< Variavel global que vai ser usado pelo gerente_execucao como extern */
int escalonadorMsqID; /**< Variavel global que tambem vai ser usada por ge... |
C | #include<stdio.h>
int main()
{
int n,rn,on,rm;
printf("This is a program to check whether a number is palindrome or not\n");
printf("Enter the number: ");
scanf("%d",&n);
on=n;
while(n!=0){
rm=n%10;
rn=rn*10+rm;
n/=10;
}
if (on==rn)
printf("%d is a palindro... |
C | #include <string.h>
#include <stdio.h>
#include <stdlib.h>
int stringlen(char s[]) {
int i = 0;
while (*s) {
i++;
s++;
}
return i;
}
char* stringcpy(char *dest, char *src) {
int i;
for (i=0; src[i] != '\0'; i++) {
dest[i] = src[i];
}
}
char* stringncpy(char *dest, char *src, int n) {
int ... |
C | /*
* $Id: newpath.c,v 1.18 2021/03/27 17:28:11 tom Exp $
*
* Author: T.E.Dickey
* Created: 02 Jun 1994
* Modified:
* 25 Mar 2021, add "-0" option.
* 13 Mar 2012, integrate into misc_tools package
* 10 Nov 2000, port to win32
*
* Function: (see usage message)
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#en... |
C | #include <stdio.h>
int test1(){
return 5;
}
char test2(int i, char c){
c = 'c';
return c;
}
float test3(){
float f = 0.0213;
return f;
}
int main(){
int i = test1();
char c = 'a';
c = test2(i, c);
float f = test3();
printf("i is %i\n", i);
printf("c is %c\n", c);
p... |
C | #include "my.h"
#define NUM 4
struct ss
{
int n;
int m;
};
void fun(void *arg)
{
int *pt;
pt=(int *)arg;
printf("work thread %d : tid = %p\n",(int)pt,pthread_self());
}
int main()
{
struct ss s={5,6};
pthread_t tid[s.n];
int ret;
int i;
for(i=0;i<s.n;i++)
{
pthread_create(&tid[i],NULL,(void *(*))fun,(void... |
C | #include <stdio.h>
#include <winsock2.h>
#include <string.h>
#pragma comment(lib, "ws2_32.lib");
struct doc_type
{
char *suffix;
char *type;
};
//Ŀɹѯļ
struct doc_type file_type[]=
{
{"html","html"},
{"jpg","jpg"},
{"txt","txt"},
{"ico","ico"},
{NULL,NULL}
};
//ɹҵ200 OKӦ
char *http_res_mes=... |
C | #include <fcntl.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "hubError.h"
#include "utils.h"
#define BUFFSIZE 512
bool sigHupOccured = false; // global variable
void handle(int s) { // parameter for if we handle multiple signals... |
C | // MAZE SOLVER
// Author: Will Moyle
// Last modified: 09/01/15
// Function header file
////////////////////////////////////////////////////////////////////////////////////
// PRE-SUPPLIED FUNCTIONS
////////////////////////////////////////////////////////////////////////////////////
/* You are pre-supplied with the ... |
C | /******UDPclient*************/
#include "UDPsetup.h"
extern const int server_port;
//#define MAXLINE 256
extern const char *LOGIN;
extern const char *QUIT;
sockaddr_in servaddr;
void *send_msg(void *arg){
int len, client_sock = *(int*)arg;
char msg_send[MAXLINE];
memset(msg_send, 0 ,MAXLINE);
while(fgets(msg_sen... |
C | //
// Baekjoon4344.c
// Algorithm
//
// Created by 양혜리 on 24/09/2019.
// Copyright © 2019 hryang. All rights reserved.
//
#include "Baekjoon4344.h"
void solution5() {
int n;
int a;
int b;
int array[1000] = {0,};
scanf("%d", &n);
for (int i = 0; i < n; i++ ) {
scanf("%d", &a);
... |
C | #include <stdio.h>
int main()
{
int arr[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
printf("Array 3 번째 원소 : %d \n ", arr[2]);
return 0;
} |
C | #include "stat.h"
extern int errno;
int testnr;
extern long lseek();
main()
{
int i;
printf("Test 8 ");
for (i = 0; i < 4; i++) {
test80();
}
printf("ok\n");
}
test80()
{
/* Test mknod, chdir, chmod, chown, access. */
int i, j;
struct stat s;
testnr = 0;
for (j=0; j < 2; j++) {
umask(0);
... |
C | #include "hash.h"
/*
* The hash function to find hash index
*/
unsigned int hashFunction(unsigned int file_index)
{
return file_index % SIZE_HASHTABLE;
}
/*
* Perform a search to find the element associated to the file_index (key)
*/
HashTableElem *search(HashTableElem **table, unsigned int file_index)
{
... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* errors.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <stdlib.h>
int i,j,k,p,q,u,v,n,ne=1;
int min,mincost=0,cost[9][9],parent[9];
int find(int);
int uni(int,int);
int main()
{
printf("Enter the no. of vertices\n");
scanf("%d",&n);
printf("Enter the cost adjacency matrix\n");
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
{
scanf("%d",&cost[i][j]);
if(... |
C | /*
factor1 : Factor one number given on the command line
Copyright (C) 2017 John L. Jolly
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
of the License, or (at your option) an... |
C | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define PFIX_CLI "[MTd]"
#define MAX_BUF_SIZE 200
int mtd_server_cmd_run_HOSTNAME(char *msg_cmd, char *message);
/* Get hostname */
int mtd_server_cmd_run_HOSTNAME(char *msg_cmd, char *message)
{
FILE *fd;
char str_cmd[MAX_BUF_SIZE], str_buf[MAX_BUF_SIZE];
... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* aux2.c :+: :+: :+: ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.