language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | #include <stdio.h>
int main(void)
{
// Populate Array and get the length of the Array
int arr[] = {11, 12, 13};
int arr_length = sizeof(arr) / sizeof(arr[0]);
// To print an Array in C we have to actually loop over it and print out each
// element from the index from which it exists
// Since ... |
C | #include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
#include <stdlib.h>
#include <grp.h>
#include <pwd.h>
#include <err.h>
int
main(void)
{
printf("real ID:\t%s\n", getpwuid(getuid())->pw_name);
printf("effective ID:\t%s\n", getpwuid(geteuid())->pw_name);
printf("real GID:\t%s\n", getgr... |
C | /*
* @author: Dawid Kopiczko
*
* File provides functions:
* - void LoadData(char* input)
* Loads data from input file and assigns it to global variables.
* Where input is a name of text file.
* - void WriteData(char* output)
* Writes data from variables to output file.
* Where output is a name of text file.
* - int ... |
C | #ifndef QUIDDITCH_H
#define QUIDDITCH_H
#define CANTIDAD_BLUDGERS 5
#define CANTIDAD_DEMENTORES 4
#define CANTIDAD_FILAS 25
#define CANTIDAD_COLUMNAS 15
/* ACA VAN LAS CONSTANTES */
typedef struct coordenada {
int fila;
int columna;
} coordenada_t;
typedef struct juego {
coordenada_t posicion_jug... |
C | /**
* CPME
* Lab6
* Michal Ormos
*
* @TODO BugFix on fase decriemiento
*/
#include<stdio.h>
#include<stdlib.h>
#include <omp.h>
#ifdef DEBUG
#define SIZE 5
#define SEED 4
#define BLOCKSIZE 5
#else
#define SIZE 129
#define SEED 129
#define BLOCKSIZE 4
#endif
int main() {
int i,j,k;
int count_seg, count_... |
C | #include "conexao.h"
#include "roteador.h"
#include "terminal.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct conexao{
Router* rot;
List* roteador;
tlista* terminal;
};
struct malha{
Conexao* equipamento;
Malha* prox;
};
struct lista{
Malha* primeiro;
Malha* ultimo;
... |
C | /**
*该程序主要是说明使用pthread_cancel来请求取消同一进程的其它线程
*/
#include "apue.h"
#include <pthread.h>
void *thr_fun1(void *arg)
{
printf("thread 1 returning\n");
return((void *)1); /* 显示只想返回一个整数,但也要强转成void *类型 */
}
void *thr_fun2(void *arg)
{
printf("thread 2 exiting\n");
pthread_exit((void *)2);
}
void *thr... |
C | #include "lists.h"
/**
* find_listint_loop - uses floyd's algo to find loop
* @head: pointer to head node of list
* Return: pointer to node where loop starts
*/
listint_t *find_listint_loop(listint_t *head)
{
listint_t *fast = head, *slow = head;
if (!head)
return (NULL);
while (fast && fast->next)
{
fast... |
C | //Handling many signals
#include <stdio.h>
#include <signal.h>
void handler( int sg)
{
if(sg == SIGINT)
printf("\nYou press Ctrl+C : ID = %d \n", sg);
else if(sg == SIGQUIT)
printf("\nYou press Ctrl+\\ : ID = %d \n", sg);
else if(sg == SIGTSTP)
printf("\nYou press Ctrl+Z : ID = %d \n", sg);
}
int m... |
C | /**
* _strncat - concatenates two strings with n bytes
* @dest: string to concate with src
* @src: string to concate to dest
* @n: number of characters to copy from src
* Return: pointer to dest
*/
char *_strncat(char *dest, char *src, int n)
{
char *p = dest;
int count = 0;
while (*dest++)
;
dest--;
whil... |
C | /*
file_test.c
gcc -g3 file_test.c -o file_test_exe
gdb file_test_exe
*/
#include<sys/stat.h>
#include<sys/types.h>
#include<fcntl.h>
#include<unistd.h>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define _BUFSIZE_ 20
int main(int argc,char* argv[]){
off_t offset1 = 0,offset2 = 0;
const char* pathn... |
C | #include <stdio.h>
int main () {
float A, B, C, media;
printf("Digite a primeira nota: ");
scanf("%f", &A);
printf("Digite a segunda nota: ");
scanf("%f", &B);
printf("Digite a terceira nota: ");
scanf("%f", &C);
media = (A*2 + B*3 + C*5)/10;
printf("Media = %f", media);
return 0;
}
|
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ms_export.c :+: :+: :+: ... |
C | // this file implements a version of malloc based on local freelist allocators for each thread
#include "freelist.h"
// use __thread (for older GCC) or C11 _Thread_local
// since I'm too lazy to implement it using pthread_setspecific and pthread_getspecific
__thread freelist_allocator _local_freelist_allocator;
// e... |
C | #include <stdio.h>
void hanoi(int n, char x, char y, char z)
{
// printf("n=%d x=%c y=%c z=%c\n", n, x, y, z);
if (n == 1) {
printf("%c -> %c\n", x, z);
} else {
hanoi(n - 1, x, z, y);
hanoi(1, x, y, z);
hanoi(n - 1, y, x, z);
}
return;
}
int main()
{
int n;
scanf("%d", &n);
hanoi(n, 'A', 'B', 'C');
r... |
C | #include <stdio.h>
int main(){
int arr[] = {20,20,40,40,13,13,11,88,88,98,99,11,11};
int elem = sizeof(arr)/sizeof(arr[0]);
int i, j;
for(i=0; i<elem; i++){
for(j=0; j<elem; j++){
if( arr[i] == arr[j] && i != j ) break;
}
if(j==elem) printf("%d\n", arr[i]);
}
return 0;
}
|
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
//0==black 1==red
struct rb_node{
int key;
char *s;
struct rb_node *right;
struct rb_node *left;
struct rb_node *parent;
int color;
};
//Poichè in un red-black-tree le foglie non sono semplici nodi NULL, ma hanno anche un colore, ossia son
//ne... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
void exit(int status);
int parse(char ui[])
{
int a,b;
int w=0; // wordsIdx
char tmp[200];
char *words[100];
for(a=0; ui[a]==' ' && a<1000; a++); // skip white spaces
while(ui[a] != '\0' && a<1000) {
for(b=0; ui[a]!='\0' && ui[a]!=... |
C | #include <stdio.h>
#define max(a, b) (a > b) ? a : b
void pArray(long long *a, long long size){
long long i;
for (i = 0; i < size; i++){
printf("%lld ", a[i]);
}
printf("\n");
}
long long kadane(long long *a, int size)
{
long long here, overall;
here = overall = 0;
long long i;
... |
C | #include<stdio.h>
#include<math.h>
#include<stdlib.h>
int main()
{
float x1,y1,x2,y2,x,y,a,g,d,f,c,b,p,q,r,s,d1,areat,areac,angle,final,i=0;
printf("Enter 1st coordinate\n");
scanf("%f%f",&x1,&y1);
printf("Enter 2nd coordinate\n");
scanf("%f%f",&x2,&y2);
d=10;
if(y1>=y2){f=y2;g=y1;}
else{f=y1;g=y2;}
for(y=f-d;... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* sdl_getter.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/wait.h>
int fdToLeft[2], fdToRight[2];
int buf[100];
void increment(int pid, long long MAX)
{
long long count = 0;
if(pid==1){
close(fdToLeft[0]);
close(fdToRight[1]);
}
if(pid==2){
c... |
C | /*Crie um programa que utilize a o cdigo de Cesar para tres posicoes.
Entre com uma string e imprima a string criptografada.*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
char string[100], cripto[100];
int i = 0;
printf("\nDigite uma palavra ou uma frase: ");
gets(string);
strcpy(cr... |
C | #include "server.h"
#include <arpa/inet.h>
#include <netinet/in.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <unistd.h>
#define MAX_CLNT 10
char *upload_rootPath = "/home/ch4njun/Project/SERVER/upload_path";
char *upload_roo... |
C | #include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdio.h>
#include <netdb.h>
#include <string.h>
void print_addrinfo(struct addrinfo* addr) {
if (addr->ai_family == AF_INET6) {
struct sockaddr_in6* saddr = (struct sockaddr_in6*)addr->ai_addr;
char ip_s[INET6_ADDRSTRLEN];... |
C | #include <stdio.h>
/**
* helpers.c
*
* Helper functions for Problem Set 3.
*/
#include <cs50.h>
#include "helpers.h"
/**
* Returns true if value is in array of n values, else false.
*/
bool search(int value, int values[], int n)
{
// only search for positive values of needle
if (value < 0)
{
... |
C | #include <stdlib.h>
#include "lists.h"
/**
* add_nodeint_end - Add a new listint_t node to the end of a list
* @head: Pointer to the pointer to the start of the list
* @n: The number to assign to integer value of the node
*
* Return: Address of the new node, NULL if it fails
*/
listint_t *add_nodeint_end(listint... |
C | #include<stdio.h>
void main()
{
int p=0;
for (int a=65;a<=70;a++)
{
p++;
for(int b=a;b<=70;b++)
{
printf("%c",b);
}
printf("\n");
for(int c=1;c<=p;c++)
{
printf(" ");
}
}
}
|
C | #include <stdio.h>
#define STACK_TYPE int
void push(STACK_TYPE value);
void pop(void);
STACK_TYPE top(void);
int is_empty(void);
int is_full(void);
void resize_stack(size_t new_size);
void create_stack(size_t size);
void destroy_stack(void);
|
C | #include <stdio.h>
#include <stdlib.h>
#pragma region Definição de Structs
// Struct para representar um nó da lista de adjacências
struct ListAdjNo {
int dest; // Vértice de destino no grafo
int peso; // Peso da aresta para grafos ponderados
struct ListAdjNo* prox; ... |
C | // 参照: 例解UNIX/Linuxプログラミング教室P180
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
int age;
printf("Welcome!\n");
printf("your age: ");
fprintf(stderr, "Input ");
scanf("%d\n", &age);
printf("Your age is %d", age);
fprintf(stderr, "Thank you! ");
printf("\nBye!");
sleep(3);
... |
C | /*
* File: avl.c
* Author: Ricardo Antunes
* Description: AVL tree implementation used by the filesystem.
*/
#include "adt.h"
#include <string.h>
#include <stdlib.h>
/* An AVL tree node. */
struct avl {
struct file* file; /* File this node points to */
struct avl* left; /* Left (smaller) node, may be NULL ... |
C | //
// Created by alex on 15.12.18.
//
#include "ast.h"
ProgramNode *ast_create_pogram_node() {
ProgramNode *programNode = (ProgramNode *) malloc(sizeof(ProgramNode));
programNode->type = GO_PROGRAM;
programNode->package_decl = NULL;
programNode->decl_section = NULL;
return programNode;
}
Package... |
C | /*
** tool.c for tools.c in /home/Liloue/CPool/Rush3/CPool_rush3
**
** Made by Laetitia POULET de GRIMOUARD
** Login <Liloue@epitech.net>
**
** Started on Sat Oct 29 17:57:30 2016 Laetitia POULET de GRIMOUARD
** Last update Sat Oct 29 21:56:30 2016 Laetitia POULET de GRIMOUARD
*/
#include <unistd.h>
char first_c... |
C | #include<stdio.h>
#include<string.h>
#include<memory.h>
int main()
{
int n;
char str[1000],*p;
while(gets(str)!=NULL)
{
p=str;
while(*p!='\0')
{
p++;
}
n=p-str;
printf("%d\n",n);
}
return 0;
}
|
C | /********************************************************************************
* File Name: __task_pid_nr_ns.c
* Description: 第3章实例训练
* Reference book:《Linux内核API完全参考手册》邱铁,周玉,邓莹莹 ,机械工业出版社.2010.9
* E_mail:openlinux2100@gmail.com
*
********************************************************... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_get_next_line.c :+: :+: :+: ... |
C | #include <stdio.h>
#include <conio.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
/* void main(void)
{
int a;int *a_ptr;
clrscr();
a=7;
a_ptr=&a;
printf("%p \n""%p \n\n",&a,&a_ptr);
printf("%d\n %p\n %d",a,a_ptr,*a_ptr);
getc... |
C | #include <stdio.h>
int main ()
{
// ganti nilai ini sesuai dengan keinginan
int a = 10;
int b = 15;
printf("%d==%d %s \n", a,b,a==b ? "true":"false");
printf("%d!=%d %s \n", a,b,a!=b ? "true":"false");
printf("%d>=%d %s \n", a,b,a>=b ? "true":"false");
printf("%d<=%d %s \n", a,b,a<=b ? "true... |
C | #include <stdio.h>
#include "average.h"
int main()
{
int v[] = { 1, 2 };
int r=0, r2;
r = average(v[0], v[1]);
r2 = average_array(v, 2);
printf("average = %d\naverage of array = %d\n", r, r2);
return 0;
}
|
C | #include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
int max = 10;
int main(){
int i = 0;
pid_t pid = fork();
if(pid == 0){
for(i; i < max; i++){
printf("child : %d\n", i);
usleep(900);
}
}
else{
for(i = 5; i < max; i++){
printf("parent : %d\n", i);
sleep(1);
}
}
return 0;
}
|
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 | #include <stdio.h>
#include <stdlib.h>
/*
* Has macros and defintions that allow variable lengthed arguments to be passed.
* va_list - The type suitable for holding information needed by macros va_start, va_arg, and va_end.
* va_start - A macro that is invoked before the variable legnth arguments list can be accesse... |
C | #include "unity.h"
#include "linkedList.h"
void setUp(void){}
void tearDown(void){}
void test_is_head_in_initialList_initialize_to_null(void)
{
TEST_ASSERT_EQUAL(0, initializeList(head, tail));
}
void test_is_tail_in_initialList_initialize_to_null(void)
{
TEST_ASSERT_EQUAL(0, initializeList(head, tail));
}
void t... |
C | 作者:丁冬
链接:https://www.zhihu.com/question/39214230/answer/80244880
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
/*
首先实现qsort需要有一个swap:
*/
#define SWAP(a, b, size)
do
{
size_t __size = (size);
char *__a = (a), *__b = (b);
do
{
char __tmp = *__a;
*__a++ = *__b;
*__b++ = __tmp;
} while (--__... |
C | //
// Created by 12 on 2020/5/31.
//
#include <stdio.h>
#include <malloc.h>
/**
* 找到数组中等于目标值的索引
*/
int findFirst(int *numbers, int target, int left, int right) {
if (numbers == NULL || left >= right) {
return -1;
}
if (numbers[left] == target) {
return left;
}
if (numbers[righ... |
C | /*
* =======================================================================================
*
* Filename: ckid.c
* Description: Check the ID of the user
* Compiler: gcc
* Author: Simon L. J. Robin | https://sljrobin.org
* Created: 2015-04-30 15:53:01
* Modified: 2016-02-13 1... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <signal.h>
#include <time.h>
#include <sys/socket.h>
#define BUFFER_SIZE 256
#define HOTE "127.0.0.1" //adresse IP
#define P... |
C | #include <stdio.h>
#include <unistd.h>
#include <stdbool.h>
#include <linuxtrack.h>
bool intialize_tracking(void)
{
linuxtrack_state_type state;
//Initialize the tracking using Default profile
state = linuxtrack_init(NULL);
if(state < LINUXTRACK_OK){
printf("%s\n", linuxtrack_explain(state));
return fa... |
C | #include <stdlib.h>
#include "binary_trees.h"
/**
* binary_tree_is_leaf - Checks if a node is a leaf
* @node: the pointer to the node to check
*
* Return: 1 if the node is a leaf, otherwise 0
*/
int binary_tree_is_leaf(const binary_tree_t *node)
{
if (!node)
return (0);
if (!node->left && !node->right)
retu... |
C | /* Write a function called strToFloat() that converts a character string into a floating-point value. Have the function
* accept an optional leading minus sign. So, the call
* strToFloat ("-867.6921");
*
* should return the value −867.6921.
*/
#include <stdio.h>
#include <stdbool.h>
int main (void)
{
float s... |
C | #include <stdio.h>
typedef struct binary_tree
{
int item;
int h;
struct binary_tree *left;
struct binary_tree *right;
}b_tree;
b_tree *create_b_tree(int item)
{
b_tree *new_tree = (b_tree *) malloc(sizeof(b_tree));
new_tree->item = item;
new_tree->left = new_tree->right = NULL;
return new_tree;
}
b_tree *c... |
C | // gcc -shared unmanaged.c -o unmanaged.dll
//
// See also:
// https://renenyffenegger.ch/notes/development/languages/C-Sharp/call-dll/index
//
#include <windows.h>
__declspec(dllexport) int StrA(const char* txt_in, char* txt_out) {
MessageBoxA(0, txt_in, "StrA", 0);
strcpy(txt_out, "This text was cop... |
C | //
// M.Gardiner, 15/7/97
//
// getparms.c - contains the definitions of a routine designed to
// parse ascii control files. The control file should be of the following
// format :-
//
// CONTROL1
// FIELD_NUMBER = 2
// CM_MESSAGE = "Hello world"
// CONTROL_CHAR = 'C'
//
// CONTROL2
// FIELD_NUMBER = 1... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "linkList.h"
LinkList *CreateList()
{
LinkList *pLinkList;
pLinkList = (LinkList *)malloc(sizeof(pLinkList));
pLinkList->head = NULL;
pLinkList->tail = NULL;
pLinkList->sumOfNode = 0;
return pLinkList;
}
int Destroy(LinkList *... |
C | #include "includes.h"
void LED_On(INT8U led_id)
{
switch (led_id) {
case LED_RUN:
GPIO_ResetBits(LED_RUN_PORT, LED_RUN_PIN);
break;
case LED_MEMS:
GPIO_ResetBits(LED_MEMS_PORT, LED_MEMS_PIN);
break;
case LED_UART:
GPIO_ResetBits(LED_UART_PORT, L... |
C | /*
MIT License
(c) Antonio de Haro, 2020
See attached LICENSE file for more info.
cpu/ports.c:
Defines a way for the kernel to communicate with IO through ports
*/
#include <cpu/ports.h>
void byte_out(unsigned short port, unsigned char data) {
__asm__ __volatile__("out %%al, %%dx"
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define N 10
typedef struct Node
{
char name[20];
struct Node *llink,*rlink;
}STUD;
STUD *creat(int);void print(STUD *);
STUD *search(STUD *h,char *x);
int main()
{
int number;
char studname[20];
STUD *head,*searchpoint;
number=N;
... |
C | #include "userlib/libnachos.h"
#include "userlib/syscall.h"
int counter = 0;
LockId lock;
void foo(void)
{
if(LockAcquire(lock))
{
n_printf("lock acquire error!\n");
return;
}
unsigned long i = 0;
counter += 1;
n_printf("\n Job %d has started\n", counter);
for... |
C | #include <stdio.h>
int main()
{
char array[100];
printf("Enter a string\n");
scanf("%s", array);
printf("Your string: %s\n", array);
return 0;
}
|
C | /* program for matrix inverse using pthread */
/* compile with the "-pthread" option for threads and "-lm" for math.h functions */
#include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <math.h>
#define MAX_ORDER 10
int n;
int det;
int matrix[MAX_ORDER][MAX_ORDER];
int altrmatrix[MAX_ORDER][MAX_ORDER];
... |
C | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <bdaddr.h>
int bachk(const char *str)
{
if (!str)
return -1;
if (strlen(str) != 17)
return -1;
while (*str) {
if (!isxdigit(*str++))
return -1;
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
struct llblock {
unsigned long tag;
long long counter;
struct llblock *next;
};
long long setsize(struct llblock *head) {
if(head == NULL) {
return -1;
}
long long counter = 0;
struct llblock *cur = head;
while(cur != NULL) {
... |
C | /* file minunit_example.c */
#include <stdio.h>
#include <stdlib.h>
#include "minunit.h"
#include "test.h"
#include "../network.h"
#include "../misc_functions.h"
int tests_run = 0;
static char * testFeedForwardReturnsCorrectOutput() {
Network * net = malloc(sizeof(Network));
double ** output;
int sizes[] = {2,... |
C | /********************************************************************
* Project 1B
* lab1b-client.c
* ------------
* NAME: Nikola Samardzic
* EMAIL: nikola.s@ucla.edu
* ID: 904799099
********************************************************************/
#include <mcrypt.h>
#include <netdb.h>
#include <fcntl.h>
... |
C | #include<stdio.h>
int main()
{
float a,b,c,p,q,r;
scanf("%f %f %f",&a,&b,&c);
p=(b*b)-(4*a*c);
if(a==0 || p<0)
{
printf("Impossivel calcular\n");
}
else
{
q=(-b+sqrt(p))/(2*a);
r=(-b-sqrt(p))/(2*a);
printf("R1 = %.5f\nR2 = %.5f\n",q,r);
... |
C | #include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
typedef struct persoon {
char* naam;
char* adres;
} persoon;
int main(int argc, char const *argv[])
{
persoon* array = NULL;
persoon* testArray;
char* tempPointer;
int i = 0;
int j;
int n = 0;
char temp[255];
do {
n++;
if(ar... |
C | #include <unistd.h>
void ft_putchar(char src)
{
write(1, &src, 1);
}
void ft_putnbr(int src)
{
long src_cpy;
src_cpy = src;
if (src_cpy > 9)
{
ft_putnbr(src / 10);
ft_putnbr(src % 10);
}
else
ft_putchar(src + '0');
}
int main(int argc, char **argv)
{
argv = 0;
if (argc > 1)
ft_putnbr(argc - 1);
... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* parse.c :+: :+: :+: ... |
C | #include "dataStructures.h"
#include "timer.h"
#include "scheduler.h"
#include "booleans.h"
#include "strUtils.h"
#include "logger.h"
#include "errors.h"
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
/*
simulates an operating system and the actions that run on it:
* inputs are a simAction li... |
C | #include <stdio.h>
#include <stdlib.h>
struct Node
{
int data;
struct Node* next;
struct Node* prev;
};
struct Node* head; // puntatore head node. definita globale cosi da usarla sempre
//Crea "new Node" nuovo nodo e restituire puntatore ad esso
struct Node* GetNewNode(int x)
{
struct Node* newNode= (struct No... |
C | #include <stdio.h> //TODO get dis outta here
#include <string.h>
#include "mapmanagement.h"
#include <assert.h>
tile create_test_tile () {
tile test_tile = malloc(sizeof(tile));
test_tile->planet_count = 5;
test_tile->planet_x = malloc(5 * sizeof(int));
test_tile->planet_y = malloc(5 * sizeof(int));
test_tile->p... |
C | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
int L[26][26];
int max(int a,int b){
if(a > b)
return a;
else
return b;
}
int lcs(char *str1,char *str2){
int n=strlen(str1);
int m=strlen(str2);
for(int i=0;i<n+1;i++){
for(int j=0;j<m+1;j++){
if(i==0 || j==0)
L[i][j]=0;
else if(str1[i... |
C | #include "sys_timer.h"
static volatile sys_time_t currentEpoch;
void sys_timerInit(void)
{
currentEpoch.sec = 0U;
currentEpoch.us = 0U;
}
void sys_timerUpdate(void)
{
currentEpoch.us += 1000U;
currentEpoch.sec += currentEpoch.us/1000000U;
currentEpoch.us %= 1000000U;
}
uint64_t sys_timerMicros(void)
{
return ... |
C | #include <stdio.h>
#include "ft_printf.h"
#include "ft_printf.c"
#include "ft_functions.c"
int eq_struct_flags(t_flags *exp, t_flags *act)
{
if ((exp->minus == act->minus) &&
(exp->precision == act->precision) &&
(exp->width == act->width) &&
(exp->zero == act->zero)
)
return (1);
return (0);
}
void in... |
C | #include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
#include <string.h>
#include <stddef.h>
#include <unistd.h>
#include <errno.h>
#include <time.h>
int slave(int rank, int comm_sz);
char *timestamp();
int main(int argc, char **argv)
{
int rank, comm_sz, r_status;
MPI_Init(&argc, &argv);
MPI_Comm_rank(M... |
C | #include <stdio.h>
int count; /* count is global */
void func1(void);
void func2(void);
int count=0;
int main(void) {
count = 10;
func1();
return 0; }
void func1(void) { int temp;
temp = count;
func2();
printf("count is % d", count); /* will print 100 */ }
void func2(void)
//Page 27
{ int ... |
C | #include "Piece.h"
struct Point{
/*
* x-coordinate of the point
*/
int x;
/*
* y-coordinate of the point
*/
int y;
/*
* boolean flag determining whether
* this piece is in check by a white piece
* @note 1 if true
* @note 0 if false
*/
int checked... |
C | #include <stdio.h>
int main(int argc, char const *argv[]){
int number, counter = 1, square = 1;
printf("Enter the number of terms to be printed in series: ");
scanf("%d", &number);
if(number <= 0){
printf("Enter a positive number.");
exit(1);
}
else if(number == 1){
printf("First number in series is 1.");
... |
C | /*
The first homework is mainly for your Linux and gcc getting ready, the common method is to use VMware and Ubuntu system.
The goal is to print "Hello World" in your linux terminal as well as a random number. Remember to change the srand to make it really random.
*/
#include <stdio.h>
#include <stdlib.h>
#include <t... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* number.c :+: :+: :+: ... |
C | /**
* @brief epoll wrapper
* @author lijk@infosec.com.cn
* @version 0.0.1
* @date 2017-6-13 15:42:32
*/
#ifndef __EVENT_EPOLL_H__
#define __EVENT_EPOLL_H__
#include <sys/epoll.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct event_epoll_s
{
int epfd;
int num;
int max;
... |
C | int removeDuplicates(int* nums, int numsSize) {
int j = 0;
for(int i = 1; i < numsSize; i++) {
if(nums[i] != nums[i-1]) {
nums[++j] = nums[i];
}
}
return numsSize != 0 ? j+1 : 0;
}
|
C | #include <stdio.h>
#include <stdlib.h>
#include "minheap.h"
minheap* createminheap()
{
minheap* heap = (minheap*)malloc(sizeof(heap)*1);
if(heap == NULL)
exit(1);
heap->size = 0;
heap->arr = (int*)malloc(sizeof(int)*heap->size);
if(heap->arr == NULL)
exit(1);
return heap;
}
void ... |
C | #include <stdio.h>
#include <stdlib.h>
/* Funçăo : Pula quantidade x de linhas
Autor : Edkallenn - Data : 03/10/2013
Observaçőes:
*/
void pula(int n); //pula n linhas
main(){
printf("Teste da funcao");
pula(10);
printf("Deve pular uma linha");
pula(15);
getch();
}
void pula(int x){
... |
C | #include <stdio.h>
int get_info (int);
int main (void)
{
int num;
int open;
puts ("请输入一个整数.");
while (scanf ("%d", &num) != 1)
{
while (getchar() != '\n')
continue;
puts ("请输入一个整数.");
}
open = get_info(num);
printf ("%d中打开的位共有%d位.\n", num, open);
return 0;
}
int get_info (int num)
{
int i;
int co... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: ... |
C | // Note that some Linux kernels will indicate an si_addr of 0 when this test
// case executes, which may result in mis-classification
#include <string.h>
#include <stdlib.h>
#include <sys/mman.h>
typedef void(*voidfn)(void);
int main(int argc, char *argv[]) {
char *a = valloc(64);
mprotect(a, 64, PROT_WRITE);
... |
C | #include "header.h"
void char_frequency(char text[]){
int d,pjg_klmt;
int huruf[100];
pjg_klmt = strlen(text);
for(d=0; d<26; d++){
huruf[d] = 0;
}
for(d=0; d<pjg_klmt; d++){
if (text[d]>='a' && text[d]<= 'z'){
huruf[text[d] - 'a']++;
}
else if (tex... |
C |
//Adds candidate to the end of list if it is a prime number. Needs sorted list of primes with '2' as first element. Skip comparison with first element '2', as input candidates should be odd numbers.
void append_if_prime(int primecandidate, int * primelist, int * length, int sqindex);
// Generates list of conse... |
C | #include "apue.h"
#include <grp.h>
#include <unistd.h>
#include <sys/types.h>
#define SIZE 16
int main(int argc, char* argv[])
{
gid_t grp[SIZE];
int size;
if ((size = getgroups(SIZE, grp)) < 0)
{
err_quit("fail to get groups..\n");
}
int i = 0;
for (;i<size;i++)
{
pri... |
C | #include <stdio.h>
typedef struct {
int min, max;
} Day_t ;
Day_t Data[30];
int main()
{
int d, sum, i, Min, Max, temp;
scanf("%d %d", &d, &sum);
for(Min = Max = i = 0; i < d; ++i) {
scanf("%d %d", &Data[i].min, &Data[i].max);
Min += Data[i].min;
Max += Data[i].max;
}
i... |
C | #include "TR_One_HAL.h"
HAL_StatusTypeDef wrt; // primoz
uint8_t val[3];
uint8_t aa;
uint8_t addr[1]; // primoz
uint16_t datr;
TERAONE_Result TrOne_WhoAmI(TRONE_Str *senStruct) {
/* Check if device is ready for communication */
//if (HAL_I2C_IsDeviceReady(senStruct->i2cHandle, senStruct->Address, 3, 200) != HAL... |
C | /*!
* @file main.c
* @brief Accel16 Click example
*
* # Description
* This showcases ability of the click board to
* read x, y, and z axes data in different resolution,
* read IC temperature and also have additional functionality
* to read ADC data. Device also has ability to store data
* in internal fifo bu... |
C | // Author: btjanaka (Bryon Tjanaka)
// Problem: (HackerRank) two-pluses
// Title: Ema's Supercomputer
// Link: https://www.hackerrank.com/challenges/two-pluses/problem
// Idea: Explore all possible sizes for the first plus, then maximize the size
// of the second plus after the first plus has been marked. It is importa... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int Manipulation (char *xtr1, char* xtr2, char* xtr3){
char *xtr = (char*)malloc(sizeof(char)*60);
strcpy(xtr,"Foo - TEST");
xtr1 = xtr; // Copy address to pointer
strcpy(xtr2,xtr); // Copy string to char array
strcpy(xtr3,xtr); ... |
C | //
// Created by cwood on 2/6/16.
//
#include <stdlib.h>
#include "packet.h"
#include "types.h"
#include "tlv.h"
typedef struct {
uint8_t version;
uint8_t packetType;
uint16_t packetLength;
uint16_t headerLength;
} _FixedHeader;
typedef struct {
uint8_t hopLimit;
uint8_t reserved;
uint8_... |
C | // CS 2110: HW09
// Erica Rabinovich
// drawing.c
#include "drawing.h"
#include "myLib.h"
#include "title_screen.h"
#include "main_screen2.h"
#include "robot.h"
#include "game_over.h"
#include "stdio.h"
unsigned short *videoBuffer = (u16 *)0x6000000;
char buffer[41];
/* getTitleScreen
* A function that will draw the... |
C | // Copyright (c) 2011, Fjölnir Ásgeirsson
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DI... |
C |
#include<stdio.h>
int main(){
int t,n,i,num;
scanf("%d",&t);
for(i=0;i<t;i++){
scanf("%d",&n);
num=0;
while(n!=0){
num=num*10+n%10;
n=n/10;
}
printf("%d\n",num);
}
return 0;} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.