language large_stringclasses 1
value | text stringlengths 9 2.95M |
|---|---|
C | #include <gmp.h>
/// Calculates the [n]th number in the Fibonacci sequence.
/// \param n nth value to calculate
/// \param r result variable
/// \return 0 | success
/// 1 | syntax error
int fib(mpz_t n, mpz_t r); |
C | #include <pbc/pbc.h>
#include <string.h>
#include <sha256.h>
//#include <keys.h>
#include <bls.h>
struct element_s* bls_hash(void* data, int length, pairing_t pairing)
{
struct element_s* new_elem = (struct element_s*)malloc(sizeof(element_t));
element_init_G1(new_elem, pairing);
element_from_hash(new_e... |
C | //An Array is a derived data-type, which is a collection of All Homogeneous elements stored in a sequential order.
#include <stdio.h>
int main()
{
//Declaration of an array.
int arr[5];
int *ptr = arr;
//int arr[]; //Not allowed.
//Base address of an array.
printf("Base Address of an array : %p\n", arr);
... |
C | //apt-get install gcc-multilib
#include "thread.h"
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
// thread metadata
struct thread {
void *esp;
struct thread *next;
struct thread *prev;
struct lock * lock;
void * sp;
};
struct thread *ready_list = NULL; // ready list
struct thread *cur_thread =... |
C | /*
* File: util.h
* Author: Georgios Varisteas
*
* Created on May 25, 2012, 1:15 PM
*/
#ifndef POND_UTIL_H
#define POND_UTIL_H
#ifdef BARRELFISH
#include <barrelfish/domain.h>
#else
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <assert.h>
#endif
#include <pthread_compat.h>
#include <confi... |
C | #include "test.h"
#include <time.h>
#define FUNC_TEST "_test"
static run_test(_test_fun f) {
#if !TEST_TIME
clock_t start, end;
start = clock();
f();
end = clock();
printf("cpu time: %ld ms ", end - start);
#else
f();
#endif
}
char buff [256] = { 0 };
int main (int argc, char **argv) {
_test_fu... |
C | short cd(char *fsfilename, char*rest, short cwd);
short cd(char *fsfilename, char*rest, short cwd)
{
FILE *fs = fopen(fsfilename,"r+");
int bitmapsize_bytes = FILESYSSIZE/BLOCKSIZE/8;
if(!rest) //change directory to root
{
//printf("change directory to root\n");
cwd = bitmapsize_bytes;
... |
C | /* a simple openMP program */
#include <stdio.h>
#include <omp.h>
int main(int argc, char *argv[]){
int num_threads = 999999;
// omp_set_num_threads(4);
// or use num_threads(4) as part of the pragma below
#pragma omp parallel
{
int thread_id = omp_get_thread_num();
#pragma omp... |
C | #include <stdio.h>
int main(int argc,char** argv) {
long i =-1;
printf("sizeof(i)=%d\n",sizeof(i));
if(i < sizeof(i)) {
printf("OK\n");
} else {
printf("error\n");
}
printf("sizeof(i)=%d\n",sizeof(i));
printf("i=%d\n",i);
return 0;
}
|
C | #include "main.h"
#include "terrain.h"
#include "player.h"
#include "screen.h"
// Converts a world x coord to a screen x coord
int getScreenX (float xPos) {
float screenOrigin = player.position.x - player.currentOffset;
int screenX = (int)(xPos - screenOrigin);
while (screenX < 0) {
screenX += ter... |
C | /*
** tools.c for Rush1 in /Rush1/step_3/src/my_unarchive
**
** Made by Antoine Baché
** Login <bache_a@epitech.net>
**
** Started on Sun Jan 10 12:15:21 2016 Antoine Baché
** Last update Sun Jan 10 12:58:02 2016 Antoine Baché
*/
#include "my_unarchive.h"
int create_dir(t_header *head)
{
mode_t mode;
#ifdef DE... |
C | #include <stdio.h>
#include "displayShell.h"
#include "complex.h"
/*Main Function*/
int main(int argc, char *argv[]) {
/*Initialize variables*/
complx c1, c2, c3;
/*Start program*/
init_bar();//Display the init bar.
input_cartesian(&c1);//Input a complex number in cartesian format.
display(&c1);//Display a comp... |
C | int numSquareSum(int n)
{
int squareSum = 0;
while (n)
{
squareSum += (n % 10) * (n % 10);
n /= 10;
}
return squareSum;
}
bool isHappy(int n) {
int slow, fast;
slow = fast = n;
do
{
slow = numSquareSum(slow);
... |
C | #include <stdio.h>
int main()
{
int a = -5;
int b = 10;
printf("\n %d - %d = %d", b, a, (b - a));
}
|
C | /* parse/flavor.c */
#include "unit-test.h"
#include "init.h"
#include "obj-tval.h"
#include "obj-properties.h"
#include "object.h"
#include "z-color.h"
static char dummy_light_1[16] = "Test Light 1";
static char dummy_light_2[16] = "Test Light 2";
static char dummy_art_light_1[24] = "Test Art. Light 1";
static char... |
C | #include <unistd.h>
#include <stdio.h>
int main(){
pid_t pid_base_process = getpid();
printf("[%d] MAIN START\n", getpid());
char *args[]={"./called_by_exec",NULL};
execvp("./called_by_exec", args);
printf("[%d] MAIN END\n", getpid()); // Will not be executed
return 0;
}
|
C | #include <stdio.h>
void printMenu(void);
void printBGNconvert(void);
void printEURconvert(void);
void printUSDconvert(void);
double dBGN = 0;
double dEUR = 0;
double dUSD = 0;
int main() {
int iChoice = 0;
char cContinue[20];
cContinue[0] = 'y';
do {
printMenu();
scanf("%d", &iC... |
C | #include<stdio.h>
//Funco com mais de um parametro, exemplo 1.
int funcao_retorno (int nume1, int nume2)
{
return nume1*nume2;
}
void main ()
{
int retorno, ex;
printf("Valor para multiplicar com 5 da funcao: ");
scanf("%d", &ex);
retorno = funcao_retorno(ex,5);
printf("Retorno da funcao:... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* heredoc.c :+: :+: :+: ... |
C | #define _GNU_SOURCE
#include <ctype.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
typedef enum {
TK_RESERVED,
TK_RETURN,
TK_IF,
TK_ELSE,
TK_WHILE,
TK_FOR,
... |
C | #include <stdlib.h>
#include <conio.h>
#include <stdio.h>
#include <math.h>
/*************found**************/
double fun(int n)
{double sum, s0, s1, s2, s; int k;
sum=1.0;
if (n<=2) sum=0.0;
s0=0.0; s1=0.0; s2=1.0;
for (k=4;k<=n;k++)
{ s=s0+s1+s2;
sum+=sqrt(s);
s0=s1;s1=s2;s2=s;
}
/*******... |
C | #include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "matrix.h"
#include "constant.h"
/*
* Функция считывания(создания) матрицы из файла. Возвращает считанную матрицу или NULL(ошибка).
* file - файл из которого производится считывание.
*/
matrix_s *create_matrix_from_file(FILE *file)
{
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <sys/sem.h>
#include <sys/shm.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/time.h>
#include "structs.h"
#include "functions.h"
int main(int argc, char **argv){
int i, j, c, M, n, *matrix, count... |
C | #include "parallel.h"
#include <mpi.h>
#define N_BORDER_VEL 5
void Program_Message(char *txt)
/* produces a stderr text output */
{
int myrank;
MPI_Comm_rank(MPI_COMM_WORLD, &myrank);
fprintf(stderr,"-MESSAGE- P:%2d : %s\n",myrank,txt);
fflush(stdout);
fflush(stderr);
}
void Programm_Sync(char *tx... |
C | #include<stdio.h>
int main()
{
int n,i,fact=1;
printf("Enter the number for Factorial\n");
scanf("%d",&n);
for(i=n;i>0;i--)
{
fact=fact*i;
}
printf("Factorial of the number %d is %d ",n,fact);
return 0;
}
|
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
int main(int argc, char *args[])
{
const int SIZE = 4096; // size of shared memory object
const char *NAME = "OS"; // name of shared memory object
int shm_fd; // shared memory... |
C | /*
CREATED BY: Benjamin Hamlin
Chapter 1 Question 3
"URLify"
PROMPT:
Write a method to replace all spaces in a string with '%20'.
You may assume that the string has sufficient space at the end to hold the additional characters,
and that you are given the 'true' length of the string
(Note: if implementing in java, pleas... |
C | /*
============================================================================
Name : main.c
Author : Nahuel
Version :
Copyright : Your copyright notice
Description : Hello World in C, Ansi-style
============================================================================
*/
#include <stdio.... |
C | #include <stdio.h>
#define NL "\n"
#define D "%d"
#define D1 D NL
#define D2 D D NL
#define D3 D D D NL
int main(void)
{
printf(D1, 1);
printf(D2, 1, 2);
printf(D3, 1, 2, 3);
return 0;
}
|
C | #include <stdio.h>
#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#define MAX_THREADS 2
#define ARR_SIZE 1200
typedef struct data_t {
int begin;
int end;
int* results;
} data_t;
void* do_the_thing(void *d) {
int i;
data_t data = *((data_t*) d);
for (i = data.begin; i <= data.end; i++) {
... |
C | #include <stdio.h>
#include <stdlib.h>
int funcion_activacion(float x, int salidas[],float t);
double sumatoria(double *entradas, double *pesos, double umbral, int size);
int main(int argc, char *argv[]){
int ctd = atof(argv[1]);
double entradas[ctd];
double pesos[ctd];
double umbral = atof(argv[argc-2]);
dou... |
C | /*
* backtrace.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h> /* for signal */
#include <execinfo.h> /* for backtrace() */
extern void dump(void);
extern void signal_handler(int signo);
extern int add(int num);
int main(int argc, char *argv[])
{
int sum... |
C | #include <stdio.h>
int main(){
printf("<< Media de n alunos. Maximo 100 alunos >>\n");
int numAlunos = 0;
printf("Entre com o numero de alunos: ");
scanf("%d",&numAlunos);
if(numAlunos > 100){
printf("Erro! O numero maximo de alunos permitidos eh 100.");
}
else{
int nota[nu... |
C | #include<stdio.h>
void main()
{
int n;
printf("\n Enter a number : ");
scanf("%d", &n);
if(n<=0)
{
printf("\n Invalid");
}
else if(n%2==0)
{
printf("\n Even");
}
else
{
printf("\n Odd");
}
}
|
C | #include "shader.h"
#include <stdio.h>
struct Shader s1;
struct Shader* s1_ptr = &s1;
struct Shader s2;
struct Shader* s2_ptr = &s2;
struct Shader s3;
struct Shader* s3_ptr = &s3;
//#define DEBUG // Prints to console
//#define VERIFYFILE // Handle file errors
//#define READFROMFILE // If the shaders are read from an ... |
C | #include <stdio.h>
int factorial(int num) {
int res = 0;
/**
* BASIS
*/
if (num == 0 || num == 1) {
return 1;
} else {
res = num * factorial(num - 1); // proses rekursif
return res;
}
}
int main() {
int num = 5;
int fact = factorial(num);
if (fact > 0) printf("\n The factorial of... |
C | #include <stdio.h>
#include <stdlib.h>
main () {
int status;
if ((status = system("date")) < 0) { // system은 fork하고, "date" command를 실행할 프로세를 exec하는데, 프로세스를 fork하는데 실패하면 -1를 리턴한다.
perror("system");
exit(1);
}
printf("exit status = %d\n", status);
if ((status = system("nosuchcommand")) < 0) { // 32512 리턴
... |
C | /*
TASKS:
LAST COMPLETED: adding handlers for possible error handlers
NEXT: Create all error possibilities and handle them
IMPORTANT NOTES:
Should add floats: so let 'f' be acceptable in number literals
When adding values to one of the arrays, ensure to update the array size in their respective analyze functions
*/
/*... |
C | #include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <time.h>
#include "memorymanager.h"
int launcher(FILE *p, char *fileName, PCB *pcb)
{
//Copy the entire file into the backing store.
char buffer[1024];
snprintf(buffer, sizeof(buffer), "cp %s BackingStore/", fileName);
system(buffer);... |
C | // NIM : Adiyansa Prasetya Wicaksana
// Nama : 13520044
// Tanggal : 9 September 2021
// Topik : Implementasi ADT List
#include <stdio.h>
#include <stdlib.h>
#include "listpos.h"
int main() {
ListPos l1;
ElType min, max;
int x, idx;
CreateListPos(&l1);
readList(&l1);
scanf("%d", &... |
C | #include "process_ancestors.h"
#include <linux/unistd.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/sched.h>
#define __PROCESS_ANCESTORS_ 332
#define ANCESTOR_NAME_LEN 16
//function def
asmlinkage long sys_process_ancestors(struct process_info info_array[], long size,... |
C | #ifndef showplot_h
#define showplot_h
// Number of cues in each scene
// FIXME: these must be manually maintained
const Scene SCENE_TEST = {2,sceneTest};
const Scene SCENE_WHITE_FLASHES = {5,sceneWhiteFlashes};
const Scene SCENE_WHITE_BREATH = {1,sceneWhiteBreath};
const Scene SCENE_CHASE = {7,sceneChase};
const S... |
C | #include <stdlib.h>
void main( void )
{
int _far *timer = (int _far *)0x0040006C;
unsigned long counter;
double x;
double y;
unsigned long hits = 0;
double pi;
srand( *timer );
for( counter = 1; counter <= 10000; counter++ )
{
x = (double)(rand() % 351) / 350;
y... |
C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "arg_complex.h"
#include <complex.h>
void printComplex(Complex c){
printf("(%5.2f,%5.2f)",c.real,c.imag);
}
Complex add(Complex a,Complex b){
Complex result = {a.real+b.real,a.imag+b.imag};
return result;
}
Complex sub(Complex a,Complex b){
Comple... |
C | /****WAP THAT ACCEPT TWO CHARACTERS FROM THE USER, AND PRINT MESSAGE THAT "BOTH CHARACTERS ARE SAME"
IF BOTH ALPHABETS ARE SAME AND IN OPPOSITE CASE OTHERWISE CONVERT THE SECOND ALPHABET AS THE OPPOSTE
CASE OF THE FIRST ALPHABET*****/
#include<stdio.h>
void main()
{
char a,b;
printf("Enter two characters : "... |
C | /* ************************************************************************** */
/* */
/* ::: :::::::: */
/* print_inf_nan.c :+: :+: :+: ... |
C | //acosh(), atanh(), sinh(), cosh(), tanh()
//csinh(), casinh()
#include <math.h>
double asinh(double x);
float asinhf(float x);
long double asinhl(long double x);
puts("x asinh(x) log(x + sqrt(x*x+1))\n"
"-----------------------------------");
for(double x = -2.0; x < 2.1; x += 0.5)
{
printf("%6.2f %15f %20f... |
C | #include "unity.h"
#include "node.h"
void setUp(void){}
void tearDown(void){}
void test_create_a_new_node_with_the_node_value_is_forty(void){
int color = 20;
int data = 40;
Node *newNode;
newNode = createNode(color, data);
TEST_ASSERT_EQUAL(20, newNode->colour);
TEST_ASSERT_EQUAL(40, newNode->value);
... |
C | #include <stdio.h>
#include <stdlib.h>
#include "algoritmo.h"
int LRU(Frame* listFrames, int lenList, int* nextIndexes) {
int index, max_time = 0x0FFFFFFF;
for (int i = 0; i < lenList; ++i)
if (listFrames[i].time < max_time) {
index = i;
max_time = listFrames[i].time;
}
return index;
}
int NRU(Fram... |
C | /********************************************************************
Author: Jordan A. Caraballo Vega
Operating Systems, Prof. Jose Sotero Esteva
Objective: Use fork to create a parent and children processes ancestral line.
Parent, son, younger son, yongest son
References: A. Silberschatz, Operating Sy... |
C | #include "register.h"
void init_registers(struct Registers * regs){
memset((void *) regs->reg, 0, 32 * sizeof(unsigned int));
}
unsigned int get_register_value(struct Registers * regs, unsigned int addr){
if(0 <= addr && addr < 32){
return regs->reg[addr];
} else {
printf("invalid address for register read\n")... |
C | //This program is similar to ascii.c except the for loop is running from A to Z, instead of a number
#include <cs50.h>
#include <stdio.h>
int main(void)
{
for (char c = 'A'; c <= 'Z'; c++)
{
printf("%c is %i\n", c, c);
}
|
C | /// @file mtga.c
/// @author Vesa Oikonen
/// @brief Multiple-time graphical analysis (including Patlak and Logan plots).
///
/*****************************************************************************/
#include "libtpcmodel.h"
/*****************************************************************************/
/*******... |
C | #include "tiny.h"
void swap_xyzw(t_xyzw *a, t_xyzw *b)
{
t_xyzw c;
c = *a;
*a = *b;
*b = c;
}
// Height-based vertex sorting, required by draw_tri.
void sort_tri(t_face *face)
{
if (face->vert[1].y < face->vert[0].y)
swap_xyzw(&face->vert[0], &face->vert[1]);
if (face->vert[2].y < face->vert[1].y)
swap_xy... |
C | #include "algorithm.h"
static int get_head_index(head_t graph[], int size, char *input_marker) {
for(int i = 0; i < size; i++) {
if(!strcmp(graph[i].node.marker, input_marker)) {
return i;
}
}
return -1;
}
static int set_elem_path_value(double head_value, elem_t *elem) {
double value = head_value * elem->... |
C | #include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <sys/time.h>
#include <time.h>
#include <math.h>
const int FACTORS = 30;
int numberMovies = 0;
int numberUsers = 0;
#define LEARNING_RATE (0.00125)
#define REGULARIZATION_PARAMETER (0.005)
#define BLOCKSIZE (256)
#define LEARNING_DATA_SIZE (9907211... |
C | //numerical recursion of square root
#include <stdio.h>
#include <math.h>
double mysqrt(double a, double x0)
{
double x1;// local variable
x1=(x0+a/x0)/2.0;
if (fabs(x1-x0)>0.00001) return mysqrt(a,x1);
else return x1;
}
main()
{
double a;//global variable
printf("please enter a: \n");
... |
C | #include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "env.h"
#include "../log.h"
char* homeDirBuffer;
// 1 - true
// 0 - false
int startsWith(char* prefix, char* text) {
unsigned prefix_length = strlen(prefix);
unsigned text_length = strlen(text);
return (text_length < p... |
C | // SHARED MEMORY - WRITE
/*
Another mechanism of Interprocess Communication.
This can be done between any two processes, That is they need not be related. By default a page of memory (4kbytes) would be allocated for Shared memory from any process.
There are three steps:
1. Initialization
2. Attach
3. Detach.
*/
#incl... |
C | // Filter and function pointers
//
#include <stdlib.h>
#include <string.h>
#include "filter.h"
void filter(void *base, size_t msize, size_t nmemb,
void **out_data, size_t *out_nmemb, predicate_t p){
size_t i;
*out_data = (void *) malloc(msize*nmemb);
*out_nmemb = 0;
for(i=0; i<nmemb; i++){
if (p(base+i*m... |
C | #include <stdio.h>
int foo(){
//this is my homework :)
return 3;
}
int main(){
for (int x = 0; x < 10;x++){
printf("hi\n");
}
return 0;
}
|
C | #define N 100 //缓冲区中的槽数目
typedef int semaphore; //信号量是一种整形数据
semaphore mutex = 1;
semaphore empty = N;
semaphore full = 0;
void producer(void){
int item;
while(1){
item = produce_item();
}
} |
C | /*
** my_strcpy for in /home/daniel_b/Piscine_C_J06
**
** Made by Erwan DANIEL
** Login <daniel_b@epitech.net>
**
** Started on Mon Oct 6 11:37:33 2014 Erwan DANIEL
** Last update Sun Feb 1 19:38:13 2015 DANIEL Erwan
*/
#include <stdlib.h>
char *my_strcpy(char *src)
{
char *new;
int size;
size = 0;
w... |
C | /**
baekjoon Oct.28.2016
for문 구구단
*/
#include <stdio.h>
int main() {
int i, n;
scanf("%d", &n);
for(i=1;i<=9;i++) printf("%d * %d = %d\n", n, i, n*i);
return 0;
} |
C | #include "grt_debug.h"
/**
* grt_debug_print_skb() - print a socket buffer
* @param label : The label to be printed before the skb data
* @param skb : The socket buffer.
*/
void grt_debug_print_skb(char * label, struct sk_buff * skb)
{
int i;
GRT_PRINT_DEBUG("%s\n", label);
for(i = 0; i < skb->len; i++){
... |
C | /***************************************************************************
* Laser Display : Display Subroutine File : display9.c *
* *
* Displays each file in the display list in turn. *
* If a ... |
C | #include <stdio.h>
#define MAX 5
void ConverToUpper(char* str)
{
for (int i = 0; ; i++)
{
if (*(str + i) == NULL)
break;
if (*(str + i) >= 'a' && *(str + i) <= 'z')
*(str + i) -= 32;
}
}
void Bigger(int* Max, int* Min)
{
if (*Max < *Min)
*Max = *Min;
}
void Gauss(int* Num, int * Sum)
{
for (int i =... |
C | #include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
int main(){
char c;
do{ system("cls");
printf("\n");
printf("======\n\n");
printf("\n\nDesea efectuar una nueva operacion (s/n)? ");
fflush(stdin);
c=toupper(getchar());
}while (c!='N');
return 0;
}
|
C |
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
FILE *file;
int i,j,k;
if(argc < 3)
{
nothing:;
return 0;
}
i=0;
next:;
while(argv[2][i] != ':' && argv[2][i] != 0)i++;
if(argv[2][i] == 0)
{
return 0;
}
k=i;
i++;
if(argv[2][i] == ' ' &&
argv[2][i+1] == '... |
C | #include<stdio.h>
#include<math.h>
void main()
{
int j,i,num,count=0, a[1000], x, y;
printf("\n");
scanf("%d", &num);
for(i=0;i<num;i++)
{
scanf("%d", &a[i]);
}
for(i=0;i<num;i++)
{
for(j=i+1;j<num;j++)
{
x=pow(a[i], a[j]);
y=pow(a[j], a[i]);
if(x>y)
{
count++;
... |
C | #include <stdio.h>
/*Essa função conta quantos digitos um string tem*/
int tamanho(char string[]) {
int cont=0;
while(string[cont]!='\0') {
cont++;
}
return cont;
}
/*Compara compara string*/
int compstring(char s1[], char s2[], int m , int n) {
int saida=0;
while( (s1[m-1]==s2[n-1]) && (n>0) ) {
... |
C | #include <stdio.h>
#include <stdlib.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <dirent.h>
#include "apue.h"
#include <sys/wait.h>
void set(){
printf("Processo corrente: %d -> Generato da: %d\n",getpid(),getppid());
}
int main(int argc, char ... |
C | /* CITS2002 Project 2 2019
Name(s): Frinze Lapuz, Thye Shan Ng
Student number(s): 22711649, 22727425
*/
#include "sifs-internal.h"
#include "helper.h"
// add a copy of a new file to an existing volume
int SIFS_writefile(const char *volumename, const char *pathname,
void *data, ... |
C | /*
* main_imgProcessingLib.h
*
* Created on: Oct 28, 2016
* Author: gnouchnam
*/
#ifndef MAIN_IMGPROCESSINGLIB_H_
#define MAIN_IMGPROCESSINGLIB_H_
#include "common.h"
#include "dirent.h"
#include "Model/DataStructure.h"
// Variables, structures and classes
#if STATIC_IMAGE
#define WAIT_TIME 0//2000
D... |
C | /* -----------------------------------------------------------------------
* smithy Tescase
* -----------------------------------------------------------------------
*/
#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"
// set NOISY_TEST t... |
C | #include <stdio.h>
int main(){
//gets/puts = for chars/strings
char b[100];
printf("input with gets, B = ");
gets(b);
printf("\noutput with puts, B = ");
puts(b);
int a;
//scanf = for all data types
printf("Input with scanf, A = ");
scanf("%d", &a);
printf("Given input with scanf = %d\n", a);
}
|
C | //2) Write a Program to remove a Specific line from the given text file.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
main(int a1,char **v)
{
int i,c=0,l=1,c1=0,b,j,n;
char ch,**p,a[100];
FILE *f;
n=atoi(v[2]);
if(a1!=3)
{
printf("Usage:: ./a.out F_name select_line\n");
return;
}
if((f=fopen(v[1]... |
C | #include<stdio.h> /* PRE DEFINED HEADER FILES */
#include<conio.h>
#include<string.h>
#include<stdlib.h>
/*MINI PROJECT :
SUBMITED BY :
Name: Sunil Joshi and Shubham Gupta
Roll No: 2007563 and 2007562
Section:CSE
MY MACHINE NAME IS : "MONTEUR"
"MONTEUR" is a german word for "ASSEMBLER";
Note: Input file... |
C | /*
* sieve.c
*
* Created on: Oct 6, 2013
* Author: sam
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(){
int n;
int *prime;
int i, k;
printf("To what number would you like to see prime numbers to? \n");
scanf("%d", &n);
prime = (int*)malloc( (n+1) * sizeof(int));
for ( i = 2; i < n;... |
C | #include "main.h"
/**
* get_line - Read entire line from stream into a buffer.
* Return: Buffer containing line read.
*/
char *get_line()
{
char *line = NULL;
int bytes_size;
size_t len = 0;
bytes_size = getline(&line, &len, stdin);
*(line + strlen(line) - 1) = '\0';
if (bytes_size < 0)
perror("Error:");
... |
C | #include <unistd.h>
int board[10][10];
int row;
int col;
int ft_error(int, char **);
int ft_vals(int, int, int, int);
void ft_putchar(char c)
{
write(1,&c,1);
}
void ft_printboard(void)
{
int i;
int j;
i = 0;
while (i < 9)
{
j = 0;
while (j < 9)
{
ft_putchar(board[i][j] + '0');
j++;
}
ft... |
C | #include <stdio.h>
typedef struct vector
{
float x;
float y;
} vec;
void vec_sum(vec v1, vec v2, float *sum_x, float *sum_y)
{
*sum_x = v1.x + v2.x;
*sum_y = v1.y + v2.y;
}
int main()
{
struct vector v1, v2;
// v1.x = 4;
// v1.y = 6;
// v2.x = 8;
// v2.y = 12;
p... |
C | #include <stdio.h>
#include <stdlib.h>
#include <dirent.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/types.h>
int main()
{
DIR *tmp=opendir("tmp");
struct dirent *dp=readdir(tmp);
char command[64],path[64];
struct stat data;
while (dp != NULL) {
if (dp->d_name[0] != '.')... |
C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
//include of usual_function.h
#include "..\headers\usual_functions.h"
typedef struct array{
int length;
int *value;
}array;
void new_random_array( array* my_array, int taille);
void read_array( array* my_array);
void clean_array(array* my_array);
void new_r... |
C | #include <stdio.h>
int fact()
{
int n, count;
unsigned long long int factorial=1;
printf("Enter an integer: ");
scanf("%d",&n);
if ( n< 0)
printf("Error!!! Factorial of negative number doesn't exist.");
else
{
for(count=1;count<=n;... |
C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int sorting(int car[]){
int i,j,n,g[]={0,1,2,3};
for(i=3;i>0;i--){
for(j=0;j<i;j++){
if(car[j]>car[j+1]){
n=car[j];
car[j]=car[j+1];
car[j+1]=n;
n=g[j];
g[j]=g[j+1];
g[j+1]=n;
}
}
}
for(i... |
C | //
// Created by Lander Brandt on 4/1/15.
//
#include <stdio.h>
#include "utility.h"
void flushStdin() {
int c;
while((c = getchar()) != '\n' && c != EOF);
}
int menu() {
int response = -1;
int read = 0;
while (response < 1 || response > 6 || read != 1) {
printf("\n1) Print the List\n");... |
C | #include <cs50.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
// Checks key to make sure each letter of
// the alpha is present once and only once
bool has_each_letter(string key);
// Checks if a string only contains letters
bool str_isalpha(string s);
// Prints a ciphertext from given
// plaintext and k... |
C | #include "file.h"
#include "assert.h"
#include "errno.h"
int main()
{
char buf[5];
buf[5]='\0';
read(0, (void*) &buf, 5);
assert(!strcmp((char*) &buf, "hello"));
assert(read(42, (char*) &buf, 5)==-EBADF);
int fd=open("tmp/read-mode.txt", O_WRONLY|O_APPEND|O_CREAT, 0200);
assert(fd!=-1);
assert(read(fd, (char*... |
C | /*
Design, Develop and Implement a Program in C for the following operations on Graph(G)
of Cities
a. Create a Graph of N cities using Adjacency Matrix.
b. Print all the nodes reachable from a given starting node in a digraph using DFS/BFS
method
*/
#include <stdio.h>
#include <stdlib.h>
int a[10][10], n, m, i, j... |
C | #include<stdio.h>
double qq(double a,int b)
{
if(b>0)
{
return a*qq(a,--b);
}
else if(b==0)
{
return 1;
}
else if(b<0)
{
return 1/qq(a,-b);
}
}
int main()
{
double a;
int b;
scanf("%lf %d",&a,&b);
a=qq(a,b);
p... |
C | #include<stdio.h>
main()
{
char a[10],b[10];
int i,k,j;
gets(a);
scanf("%d",&k);
j=0;
for(i=0;i<k;i++)
{
b[j]=a[i];
j++;
}
b[j]='\0';
printf("%s",b);
}
|
C | #include <stdio.h>
#include <unistd.h>
#include <sys/socket.h>
#include <sys/types.h>
#include "info.h"
#include "signal.h"
#include <string.h>
#define SOCKET_ERR -1
#define BIND_ERR -2
#define RECV_ERR -3
int sockfd;
int sigint_flag = 0;
void sigint_catch(int signum)
{
close(sockfd);
unlink(SOCKET_NAME);
... |
C | //hollow diamond star pattern
#include<stdio.h>
int main()
{
int i,j,n,count,l=0,k,m;
printf("enter no. of rows in upper half:");
scanf("%d",&n);
m=n;
for(i=1;i<=n;i++)
{
for(j=1;j<=n+1-i;j++)
printf("*");
count=i;
while(count<=2*l)
{
printf(" ");
... |
C | #include "log.h"
#ifndef UNUSED
#define UNUSED(x) ((void)x);
#endif
#ifndef min
#define min(a, b) ((a) <= (b) ? (a) : (b))
#endif
#ifndef max
#define max(a, b) ((a) >= (b) ? (a) : (b))
#endif
static inline void do_output(const char *msg, bool endl)
{
fprintf(stderr, "%s%s", msg, endl ? "\n" : "");
}
static inli... |
C | //Program to copy the contents of one array into another in the reverse order.
#include<stdio.h>
int main()
{
int i,j,arr1[10],arr2[10];
printf("Enter 10 elements of an array: \n");
for(i=0; i<=9; i++)
scanf("%d",&arr1[i]);
for(i=0,j=9; i<=9; i++,j--)
arr2[i]=arr1[j];
... |
C | #include <stdio.h>
#include <stdlib.h>
#include "listaencadeada.h"
int main(void){
void *Lista = criarLista();
for(int i = 1 ; i <= 10 ; i++){
incluirLista(Lista, i);
}
void *no = buscar(Lista, 4);
buscar(Lista, 15); // Imprime a mensagem que não encontrou o nó
imprimirLi... |
C | #include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
int main()
{
char buf[100];
getcwd(buf, 100);
printf("current dir: %s\n", buf);
if (mkdir("testdir", 0777)) {
perror("create failed");
}
chdir("testdir");
getcw... |
C | /**
* This program use static library funcions
* author : Naresh
* email :nareshchemchem35@gmail.com
* date :08-09-2021
* */
#include<stdio.h> /* required for printf */
/* main program */
main()
{
int r;
printf("Hello");
r=add(10,20);
printf("r=%d\n",r);
r=sub(10,20);
printf("r=%d\n",r);
}
|
C | #include "types.h"
#include "user.h"
int
main(int argc, char const *argv[])
{
int ticks = 50;
if (argc > 2)
{
printf(1,"usage: sleep [ticks]\n");
exit();
}
if(argc == 2)
ticks = atoi(argv[1]);
sleep(ticks);
exit();
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.