language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
/************************************************************************* > File Name: 01test.c > Author: scc_embedclub > Mail: scc_ddcx@163.com > Created Time: 2015年08月10日 星期一 11时03分36秒 > Version: 1.0 ************************************************************************/ #include<stdio.h> ...
C
#include "common/test.h" #include "platform/gl.h" #include "common/gl.h" #include "common/scene_setup.h" #include <stdlib.h> typedef struct { ShaderPair shads; SceneFramebuffer fb; Geometry geo; SceneAttribLocs sceneAttribLocs; SceneUniformLocs sceneUniformLocs; GLuint tex; } Private; static T...
C
/* ----------------------------------------------------------------------- *Test great_hall card * * cardtest4: cardtest4.c dominion.o rngs.o * gcc -o cardtest4 -g cardtest4.c dominion.o rngs.o $(CFLAGS) * ----------------------------------------------------------------------- */ #include "dominion.h" #i...
C
#include <omp.h> #include <stdio.h> #include <stdlib.h> #define NUM_STEPS 1000 #define NUM_OPS 50 int main() { int num = 0; #pragma omp parallel for num_threads(4) for (int i = 0; i < NUM_STEPS; i++) { for (int j = 0; j < NUM_OPS; j++) { #pragma omp atomic num++; } for (int j = 0; ...
C
#include "../include/msg.h" #include <stdio.h> uint8_t calc_parity_bit(client_msg_t msg) { uint8_t counter = 0; msg &= ~PARITY_BIT; while (msg) { counter += msg % 2; msg >>= 1; } return counter % 2; } uint8_t get_parity_bit(client_msg_t msg) { debug_print("Get parity bit of %04x\n", msg); return (uint8_...
C
#include<stdio.h> #include<string.h> int main(void) { int str[100] = {0}; int i,j,k,n,max,min; int num; scanf("%d", &num); for(n=0;n < num;n++) scanf("%d",&str[n]); j = k = 0; max = str[0]; min = str[0]; for(i=0;i < num;i++) if(str[i] < min) { min = str[i]; j=i; } else if(str[i] > max) { ...
C
#include<stdio.h> #include<stdlib.h> struct node{ int data; struct node* next; }; void push(struct node **head,int data) { struct node *ptr1 = (struct node*)malloc(sizeof(struct node)); struct node *temp = *head; ptr1->data = data; ptr1->next = *head; if(*head != NULL) ...
C
#include <unistd.h> #include <stdio.h> #include <stdlib.h> #define MAXLINE 256 int main(){ int n; int fd[2]; pid_t pid; char line[MAXLINE]; if(pipe(fd)<0) printf("pipe error\n"); if((pid=fork())<0) printf("fork error\n"); else if(pid>0){ //parent pid close(fd[0]); write(fd[1],"hello world\n",12); }else{ ...
C
#include<stdio.h> #include<stdlib.h> int cmp(const void*a,const void *b) { return *(int*)a-*(int*)b; } int main() { int n,*arr,i,temp,counter; scanf("%d",&n); arr=(int*)malloc(sizeof(int)*n); for(i=0;i<n;i++) scanf("%d",&arr[i]); qsort(arr,n,sizeof(int),cmp); counter=0; for(i=0;i<n;) { counter++; temp=...
C
#include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <fcntl.h> #include <sys/mman.h> #include <time.h> #include <pthread.h> #include "sem.h" int num_children = 1; int iterations = 3; pid_t pids[1000]; int i,j; int n = 10; int pid; int count = 0; char phil_a...
C
// CBSD Project, 2018 // olevole@olevole.ru #include <stdio.h> #include "output.h" #include <unistd.h> #include <string.h> #include <stdlib.h> #include <syslog.h> #include <sys/time.h> #include "var.h" #include "input.h" #include "logger.h" /* Low level logging. To use only for very big messages, otherwise * serverLo...
C
/* ** xclose.c for my_xclose in /home/mille_j//42sh/src/tools ** ** Made by john mille ** Login <John@epitech.net> ** ** Started on Sat Dec 18 20:39:39 2010 john mille ** Last update Sat Dec 18 20:47:41 2010 john mille */ #include <stdlib.h> #include <unistd.h> int my_xclose(const int fd) { int xclose; xclo...
C
/* : ڽ ¶ ̵ ״ ϴ α׷ ۼϽÿ. */ #include <stdio.h> int main() { printf("3\n"); printf("ironhak1106\n"); return 0; }
C
#include<stdio.h> int main() { char c; int lowercasevowel, uppercasevowel; printf("enter a alphabet"); scanf("%c",&c); lowercasevowel=(c == 'a'|| c == 'e'|| c == 'i'|| c == 'o' || c == 'u'); uppercasevowel=(c == 'A'|| c == 'E' || c == 'I'|| c == 'O'|| c == 'U'); if(lowercasevowel||uppercasev...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct celula{ char *dado; struct celula *prox; }celula; typedef struct fila{ int tam; celula *head; celula *tail; }fila; celula *criaCelula(){ celula *l = malloc(sizeof(celula)); l->dado = malloc(26 * sizeof(char)); l->prox = NULL; ...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include <sys/time.h> #define MAX 8 double A[MAX][MAX]= {1,2,3,2,5,2,3,1, 5,9,3,4,5,6,7,4, 4,4,7,7,8,4,3,1, 1,2,4,5,7,8,9,2, 1,2,3,8,9,7,1,2, 1,2,1,2,4,3,3,8, ...
C
#include <OS.h> #include "timer.h" #define UCLOCKS_PER_SEC 1000000 static long long cpu_speed = 0; static inline long long read_rdtsc(void) { long long result; asm volatile("rdtsc" :"=A" (result)); return(result); } static long long get_cpu_speed() // based on mame { long long a, b, start, end; a = system_ti...
C
#include "lists.h" /** * check_cycle - checks if a linked list has a loop * @list: the linked list to check * Return: 0 - the linked list has no loop. * 1 - the linked list has a loop. */ int check_cycle(listint_t *list) { listint_t *snail, *cheetah; snail = cheetah = list; while (snail && cheetah && ...
C
#include <stdio.h> int ft_str_is_uppercase(char *str) { int i; i = 0; while (str[i] != '\0') { if (((str[i] < 'A') || (str[i] > 'Z'))) { return (0); } i++; } return(1); } /*int main(void) { char *str; char number; str = "za"; number = ft_str_is_uppercase(str); printf("%d", number); }*/
C
/*---------------------------------------------------------------- * * Programacion avanzada: Funciones Estandar de E/S * Fecha: 22-Feb-2019 * Autor: A01700820 Carlos Roman Rivera * *--------------------------------------------------------------*/ #include <stdio.h> #include <ctype.h> #include <stdlib.h> #includ...
C
/* ************************************************************************** */ /* */ /* :::::::: */ /* export.c :+: :+: ...
C
#include "holberton.h" #include <stdlib.h> /** * free_grid - frees a 2 dimensional grid previously created * by alloc_grid * @grid: to be freed * @height: number of columns of grid * * Return: nothing */ void free_grid(int **grid, int height) { int i = 0; while (i < height) { free(grid[i]); i++; } free(grid)...
C
#include <msp430.h> /** * main.c */ int main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer P1DIR |= 0x41; //Set path output to LED Port 1.0 and LED Port 1.6 P1REN |= BIT3; //enable resistor to connect LED and button P1OUT |= BIT3; //Enable button as output P1OUT &= ~BIT0; // Start the...
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
class Set { // Simple set class, storing ints in a bit vector. Assumes 32-bit words. public: Set() : els(0) {} Set(int len) : els((len+30)/31) {} int size() const { return els.size(); } void init(int len) { els.resize((len+30)/31); } Set& operator= (const Set &a) { els.resize(size()); for(int ...
C
/* compute distance between two points on a sphere (sDistance) or an ellipsiod (gDistance) . Units are degrees and km. for testing compile with -DTEST Link: -lproj -lm (C) Einar Kjartansson, November 2016 */ #include <stdio.h> #include <stdlib.h> #include <math.h> #include <geodesic.h> #include "ray.h...
C
#include<stdio.h> void main() { char string[5][20],rk[20]; int i,j; printf("Enter names of things \n"); //while(i<5) //scanf("%s",string[i++]); for(i=0;i<5;i++) scanf("%s",string[i]); for(i=0;i<4;i++) { for(j=0;j<=4-i;j++) { if(strcmp(string[j-1],string[j])>0) { strcpy(rk...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_printf.c :+: :+: :+: ...
C
#include <sys/msg.h> #include <sys/ipc.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <errno.h> #include <signal.h> #include <sys/types.h> #include <sys/ipc.h> #include <sys/msg.h> #include <unistd.h> #include "headers.h" int client_id; int self_id = -1; void client_exit(){ printf("Finish...
C
#include<stdio.h> #include<limits.h> typedef unsigned float_bits; float_bits float_i2f(int i); unsigned leftmost_one_loc(unsigned i); float_bits f2u(float f); float u2f(float_bits f); int main() { for(int i = INT_MIN; i <= INT_MAX; i++) { float myself_cast = u2f(float_i2f(i)); float normal_cast = (float...
C
#define _CRT_SECURE_NO_WARNINGS //파일 입출력 명령어 그대로 쓰기 위해 define #include <stdio.h> #include <stdlib.h> #define MAX_VERTEX 50 #define MAX_STACK_SIZE 1000 typedef struct GraphNode { int vertex; GraphNode *link; }GraphNode; typedef struct GraphType { int n; //정점의 개수 GraphNode *adj_list[MAX_VERTEX]; }GraphType; //노...
C
/** * Implements a dictionary's functionality. */ #include <stdbool.h> #include <ctype.h> #include <stdio.h> #include <cs50.h> #include <string.h> #include <stdlib.h> #include "dictionary.h" /** * Returns true if word is in dictionary else false. */ bool check(const char *word) { // Initialise check pointer ...
C
#include <stdio.h> #include <string.h> #define STACK_SIZE 10 char stack[STACK_SIZE]; int top = -1; int isEmpty() { return top == -1; } int isFull() { return top == STACK_SIZE - 1; } char peek() { return stack[top]; } char pop() { if (!isEmpty()) { return stack[top--]; } else { p...
C
//Jan 24, 17 // //Illustrates getopt() command. // // /* scene 1: -d option with an arguement. dguai:~/workspace/Head First C/ch 3 $ ./a.out -d now deliver now. scene 2: -d option without an arguement dguai:~/workspace/Head First C/ch 3 $ ./a.out -d ./a.out: option requires an argument -- 'd' Wrong argument. sc...
C
// Demonstrates usage of TEveJetCone class. // Author: Jochen Thaeder const char* esd_geom_file_name = "http://root.cern.ch/files/alice_ESDgeometry.root"; void jetcone() { TEveManager::Create(); using namespace TMath; TRandom r(0); // -- Set Constants Int_t nCones = 10; Int_t nTracks = 200; ...
C
/** * @brief Funcion Borrar un Registro * @param Recibe como primer parametro la estructura Personas y como segundo parametro un valor entero * @param busca en el array, buscando el dni, si lo encuentra nos avisa que persona es y la borra de manera logica * @return No devuelve valor. */ #include <stdio.h> #inc...
C
#include "holberton.h" /** * read_textfile - read text file * @filename: path to file * @letters: buffer size * Return: num of bytes */ ssize_t read_textfile(const char *filename, size_t letters) { ssize_t num = 0; char *buffer; int fd; if (filename == NULL) { return (0); } buffer = malloc(sizeof(char)...
C
#include<stdio.h> int main(){ int T,tcase=1; scanf("%d",&T); while(T--){//notice long long a,b,c; scanf("%lld%lld%lld",&a,&b,&c); if(a+b>c){ printf("case #%d:true\n",tcase++); } else{ printf("Case #%d:false\n",tcase++); } } retu...
C
/* * network/network.c: implementation of the MNP process. * * CS60, March 2018. */ #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <string.h> #include <arpa/inet.h> #include <signal.h> #include <netdb.h> #include <assert.h> #include <sys/uts...
C
#include <stdio.h> #include <string.h> int main() { char a[25] = " this is a "; char b[25] = " this is b "; char c[25] = " we dont care about c "; int i; printf("\nThose 3 strings will get modified after using strcpy\n\n"); printf("%s\n%s\n%s\n", a, b, c); printf("\nNow using magic\n\n"); strcpy(c, a); printf("%s\n...
C
// input three angle of a triangle. Check it is valid or not #include <stdio.h> int main() { float a, b, c; printf("Enter three angles to check that it will form a valid traingle or not. \n"); scanf("%f %f %f", &a, &b, &c); if(a+b+c==180) printf("valid triangle \n"); else printf("invalid triangle \n"); r...
C
#include "system.h" #include "FreeRTOS.h" void vApplicationTickHook( void ) { system_tick(); } void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ) { /* If the buffers to be provided to the Timer task are declared ins...
C
#include "stringobj.h" StringObj *f77xml_StringObj_new(unsigned int maxlen) { StringObj *str; str = (struct StringObj *)malloc(sizeof(struct StringObj)); str->str = (char *)malloc((maxlen+1)*sizeof(char)); bzero(str->str, maxlen+1); str->maxlen = maxlen; return str; } void f77xml_StringObj_delete(StringObj *s...
C
#include "apue.h" #include <sys/wait.h> static void sig_int(int); int main(int argc, char *argv[]) { char buf[MAXLINE]; pid_t pid; int status; int len; if (signal(SIGINT, sig_int) == SIG_ERR) err_sys("signal error"); printf("%% "); while (fgets(buf, MAXLINE, stdin) != NULL) { ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* correct_cast_flags.c :+: :+: :+: ...
C
#include <stdio.h> #include <stdlib.h> #include "Beer.h" static int g_nNumberOfBeers=0; /* Made static so it only can be accessed here */ /* g_ is for "global" */ struct Beer *addBeer(struct Beer *beer) { struct Beer *new_beer; /* Allocate space for new element/node: */ new_be...
C
#include <func.h> #define n 10000000 int main(){ int shmid=shmget(1000,4096,0600|IPC_CREAT); ERROR_CHECK(shmid,-1,"shmget"); int *p=(int *)shmat(shmid,NULL,0); *p=0; if(!fork()){ printf("this is child process!\n"); for(int idx=0;idx<n;++idx){ *p=*p+1; } return 0; } else{ printf("this is parent pr...
C
#include "Rasteron.h" #include "OS_Util.h" // Global Definitions GradientLattice lattice1 = { 3, 3, 0xFF0000FF, 0xFF00FF00 }; GradientLattice lattice2 = { 12, 12, 0xFFFF00FF, 0xFF00FFFF }; GradientLattice lattice3 = { 64, 64, 0xFF000000, 0xFFFFFFFF }; Rasteron_Image* solidImg; Rasteron_Image* randNoiseImg; Rasteron_...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> /* A Handler for a temporary file created with write_temp_file. In this implementation it's just a file descripter */ typedef int temp_file_handle; /* Writes length bytes from BUFFER into a temporary file. The temporary file is immed...
C
#include<stdio.h> void swap(int *p, int *q) { int tmp = *p; *p = *q; *q = tmp; } int main() { int a[] = {3, 0, 5, 1, 4, 6, 2, 9, 8, 7}; int i ,j; for(i = 0; i < 10; i++) { for(j = i + 1; j < 10;j++) { if(a[i] > a[j]){ swap(&a[i], &a[j]); } } } int k; for(k = 0; k < 10; k++) { print...
C
#include<stdio.h> int main(){ int a[3][4]={{10,9,2,1},{12,1,11,3},{4,13,21,14}};//ʼά int min=a[0][0],row=1,column=1;//ʼҪõı for(int i=0;i<=2;i++){//ÿԪؽб for(int j=0;j<=3;j++){ if(a[i][j]<min){//ָСԪ min=a[i][j],row=i,column=j;//¼Ԫؼбꡢб } } } printf("min=%d, row=%d, column=%d.",min,row+1,...
C
#include<stdio.h> int s[100],n,top=-1; void push() { int item; if(top<n-1) { printf("Enter the item to push to stack:-"); scanf("%d",&item); top++; s[top]=item; } else printf("STACK OVERFLOW"); } void pop() { int item; if(top<0) printf("STACK EMPTY"); else { item=s[top]; top--; printf(...
C
#include <setjmp.h> #include <stdio.h> static int i = 0; static jmp_buf buf; #define ASM {\ asm ("movl %%esp, %0" "\n\t" "movl %%ebp, %1"\ : "=r"(x), "=r"(y));\ }; static int x,y; int foo(){ ASM printf("x=%d || y=%d \n",x,y); int j; if (setjmp(buf)){ for (j=0; j<5; j++){ i++; }...
C
// // strp.c // hls-lesson8 // // Created by liusong huang on 2019/5/7. // Copyright © 2019 liusong huang. All rights reserved. // #include "strp.h" void T1(){ void test1(); test1(); void test2(); test2(); int a=10; printf("\n"); // void test3(); // test3(); ...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* init_matrices.c :+: :+: :+: ...
C
/* c4下,g++编译通过。如果没有通过,请在c4设置中,g++参数 -lm前添加-std=c++11 (注,前后有空格) */ /* 使用sdl自带方向键控制,有点不好控制,自己慢慢来 */ /* 这里仅提供模板,更多功能,自己添加,去下载我制作的apk吧! */ /* c4droid吧,TTHHR制作,改写时请保留原注释! */ #include<SDL/SDL_image.h> #include <SDL/SDL.h> #include <SDL/SDL_mixer.h> #include<time.h> // 头文件 #define SCREEN_WIDTH 480 // 所使用的图片的宽,自己修改 #def...
C
/* threshcrypt ui.c * Copyright 2012 Ryan Castellucci <code@ryanc.org> * This software is published under the terms of the Simplified BSD License. * Please see the 'COPYING' file for details. */ #include <termios.h> #include <unistd.h> #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <stdint.h> ...
C
#include <stdio.h> #include <stdlib.h> typedef struct fila{ int *queue; int size; int first; int last; } fila; int push(fila*damae, int value){ //printf("Value: %d\n",value); (damae)->last++; if(((damae)->last - (damae)->first)==((damae)->size)){ (damae)->size *= 2; int * n...
C
#include <stdio.h> #include <string.h> int main (void) { char buff[256]; //car printf ("Do you have at least one car?\n"); fgets (buff, sizeof(buff), stdin); char answerCar; sscanf (buff, "%c", &answerCar); //hourse short hourse; printf ("How many hourses do you have?\n"); scanf ("%hd", &hourse); ...
C
#include<stdio.h> main() { int a=10,b=20,c=0,i; c=a^b; for(i=0;c;i++) c=c&c-1; printf("%d",i); }
C
// // Created by wahba on 12/05/2016. // #include "helper/readFile.h"//FULLY DOCUMENTED #include "helper/basic.h" #include "helper/dependant.h" #include "helper/common.h" //pre Define void enclosed (char img_in[50][50]); void outline (char img_in[50][50]); int main() { //--------the essential pa...
C
#define _CRTDBG_MAP_ALLOC #include <stdlib.h> //NULL strtod() #include <crtdbg.h> #include "leptjson.h" #include <assert.h> //assert() #include <errno.h> //errno, ERANGE, malloc(), realloc(), free() #include <ctype.h> //isdigit() #include <math.h> //HUGE_VAL #include <string.h> //memcpy() //ṩ14AP...
C
#include<stdio.h> #include<stdlib.h> #include "hdr/107_sorting.h" int a[7][7] = { {0,16,12,21,0,0,0}, {16,0,0,17,20,0,0}, {12,0,0,28,0,31,0}, {21,17,28,0,18,19,23}, {0,20,0,18,0,0,11}, {0,0,31,19,0,0,27}, {0,0,0,23,11,27,0} }; int main() { int i,j; int** p; struct ans b; p = malloc(7*sizeof(int *)); for...
C
#include <stdlib.h> #include <stdio.h> #include <string.h> #include <ctype.h> #include <signal.h> #include <unistd.h> #include "window.h" #include "io_functions.h" #include "db.h" /* Struct encapsulating information about a client */ typedef struct Client { Window *window; // The client window pthread_t thread; } ...
C
#define TAB_SIZE 4 extern char filename[50]; extern int NOL; extern char** CODE; extern int CURSOR[2]; void replaceTabWithSpaces(); void preprocessing(); void replaceTabWithSpaces(){ int i; for(i=0; i<NOL; i++){ int index = strpos(CODE[i],"\t",0); if(index == -1) continue; substrDelete(CODE[i],index,index...
C
/* * Morris preorder traversal */ #include <stdio.h> #include <stdlib.h> #include <time.h> typedef struct bstnode { struct bstnode *left; struct bstnode *right; int val; } bstnode_t; bstnode_t * make_bstnode(int val) { bstnode_t *node = calloc(1, sizeof(bstnode_t)); node->val = val; return node; } bstnode...
C
#include <stdio.h> int main(void) { int a[] = {5, 15, 34, 54, 14, 2, 52, 72}; int *p; p = a; /* printf("%d\n", p == a[0]); illegal: mismatched types */ printf("%d\n", p == &a[0]); /* true */ printf("%d\n", *p == a[0]); /* true */ printf("%d\n", p[0] == a[0]); /* true */ }
C
#include <stdio.h> #include <stdlib.h> #include <sys/mman.h> #include <sys/stat.h> #include <fcntl.h> #include <semaphore.h> #include <sys/types.h> #include <unistd.h> #define check_error(expr, msg) \ do { \ if(!(expr)){ \ fprintf(stderr, "%s\n", msg); \ exit(EXIT_FAILURE); \ } \ } while(0) #define ARRAY...
C
/* 把字符串看做指针 */ #include <stdio.h> int main(int argc, char const *argv[]) { printf("%s, %p, %c\n", "We", "are", *("space faters" + 1)); getchar(); return 0; }
C
/* * $XConsortium: XTextExt.c,v 11.24 89/12/11 19:10:40 rws Exp $ * * Copyright 1989 Massachusetts Institute of Technology */ #include "Xlibint.h" #define min_byte2 min_char_or_byte2 #define max_byte2 max_char_or_byte2 /* * CI_GET_ROWZERO_CHAR_INFO_2D - do the same thing as CI_GET_CHAR_INFO_1D, * except tha...
C
#include <stdio.h> #include <string.h> void permute(char *ptr,int len,int c){ int i; char temp; if (c == len -1){ printf("%s\n",ptr); } else { for(i=c; i < len ; i++){ temp = ptr[c]; ptr[c] = ptr[i]; ptr[i] = temp; permute(ptr,len,c+1); temp = ptr[c]; ptr[c] = ptr[i]; ...
C
/* * */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <semaphore.h> #include <signal.h> #include "ring_buffer.h" #define ALEXA_RECON_PART_END ("\r\n--this-is-a-boundary--\r\n") #define RIN...
C
/* roman_numeral_calc.c Andrew Howard - 2016 This file defines library functions that allow the user to add and subtract Roman numeral numbers. Other functions facilitate the conversion between Roman numerals and decimal numbers. The largest Roman numeral supported is 3999 (MMMCMXCIX) and the smallest is 1 (I). ...
C
#define PI (4.*atan(1.)) #include <math.h> double f(double x) { return 2 * pow(sin(3 * PI - 2 * x), 2) * pow(cos(5 * PI + 2 * x), 2); }
C
/* * GccApplication1.c * Created: 2/27/2019 6:54:28 PM * Author: cuicas */ //RUNNING OFF 1MHZ #include <avr/io.h> int main () { DDRB = 0xff; //set all of portB to output TCCR1B = (1<<CS12) | (1<<CS10);//setting these bits specifically 5 so that pre-scaler is 1024 int count = 0; //this is how I...
C
/* ** EPITECH PROJECT, 2018 ** socket.c ** File description: ** socket */ #include <sys/socket.h> #include <netdb.h> #include <ifaddrs.h> #include <unistd.h> #include <stdio.h> int memsetzero(void *ptr, size_t size) { char *tmp = ptr; if (tmp == NULL) return (-1); for (size_t i = 0; i < size; i++) tmp[i] = 0;...
C
#pragma once typedef struct vector_implementation { int size; int capacity; int *data; } vector; // return pointer to new vector vector* vector_create(); // returns vector size int vector_size(vector* v); // returns capacity int vector_capacity(vector* v); //return true if size is 0 int vector_is_empty...
C
#include"delay.h" __IO uint32_t TimingDelay; /*延时1us函数*/ void delay_us(__IO uint32_t usnTime) { TimingDelay = usnTime; while(TimingDelay != 0); } void delay_ms(__IO uint32_t msnTime) { TimingDelay = msnTime * 1000; while(TimingDelay != 0); } static volatile uint32_t usTicks = 0; // cycles per microsecond vo...
C
#include<stdio.h> #include <math.h> void main() { int i,n,v,v1,number=0; printf("Enter a value:"); scanf("%d",&n); v=n; v1=ceil(sqrt(n)); for(i=2;i<=v1;i++) { if(v%1==0) number=1; } if ((number==0&& v!=1)||v==2||v==3) printf("%d is a prime number",v...
C
#include <stdio.h> #include <stdlib.h> #include <time.h> void clearstdin(void) { char temp; while((temp=getchar())!='\n'); } int main() { int num; srand(time(NULL)); num = rand() % 100 + 1; char input[3]; int guess = 101; int correct = 0; printf("Press Enter to continue"); while (correct == 0) { ...
C
#pragma once // CX basic low-level file i/o // This acts as a bridge to the operating system. It does synchronous I/O with // only the OS-provided buffering. Unlike the C standard library, I/O is not // line-oriented in any way. #include <cx/cx.h> CX_C_BEGIN typedef struct FSFile FSFile; enum FSOpenFlags { FS...
C
#include <unistd.h> #include <fcntl.h> #include <string.h> #include <stdio.h> int main(void){ int fd = open("a.txt",O_CREAT|O_WRONLY|O_TRUNC,0644); int i= 0; while(1){ int fd1 = dup2(fd,i); printf("%d\n",fd1); i++; if(fd1<0) printf("over\n"); } }
C
#include <stdio.h> int main() { int number; printf("Enter a digit: "); /* * Store value of the number the user entered into the command line * in number. */ scanf("%d", &number); printf("You entered: %d", number); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <limits.h> #include <pthread.h> struct Customer { int id; /* round */ int arrive; int cont; // continuously play round int rest; int total; int start; // should start int accum; int explored; int prewait; struct C...
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> int main() { char x1,x2,result; // Beispiel 1: x1 = 35; x2 = 85; result = x1 + x2; printf("Beispiel 1: %hi + %hi = %hi\n",x1 ,x2, result); // Beispiel 2: x1 = 85; x2 = 85; result = x1 + x2; printf("Beispiel 2: %hi + %hi = %hi\n", x1, x2, result); ...
C
#include <stdio.h> int main() { int n = 0; int num; printf("Ҫλ"); scanf("%d",&num); n++; num /= 10; while ( num > 0 ) { n++; num /= 10; } printf("λ%d",n); system("pause"); return 0; }
C
void ft_putchar(char ch); void ft_putstr(char *str) { while (*str) { ft_putchar(*str); str += 1; } } int ft_strcmp(char *s1, char *s2) { int i; i = 0; while (s1[i] && s2[i]) { if (s1[i] != s2[i]) return (s1[i] - s2[i]); i += 1; } ...
C
#include <stdio.h> #include<math.h> int f(int x,int y) { float result=pow(x,2)+y; double sr=sqrt(result); return ((sr - floor(sr)) == 0); } int main() { long x,y; long result=0,flag=0; long i; long j; scanf("%ld %ld",&x,&y); for(i=1;i<=x;i++) { for(j=1;j<=y;j++) {result=f(i,j); ...
C
#include "AEEDebugger.h" static uint32 OEMDEBUGGER_AddRef(IDEBUGGER* po); static uint32 OEMDEBUGGER_Release(IDEBUGGER* po); static int OEMDEBUGGER_QueryInterface (IDEBUGGER *pMe, AEECLSID id, void **ppo); static void OEMDEBUGGER_SetCtx(IDEBUGGER* po, void* pbCtx); static void* OEMDEBUGGER_GetCtx(IDEBUGGER* po)...
C
#include "holberton.h" #include <stdio.h> /** *main - accepts void prints 1 to 100 * but if something is divisable by 3 * print fizz and buzz if 5 both * if devisable by both *Return: 0 */ int main(void) { int i; for (i = 1 ; i <= 99 ; i++) { if ((i % 3) == 0 && (i % 5) == 0) printf("...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <wave.h> #include <snddevice.h> int main(int argc, char *argv[]) { WaveDecoder decoder; SndPlayer player; int i, ret; if(argc < 2) { fprintf(stderr, "用法:%s WAVE音频列表\n", argv[0]); return EXIT_FAILURE; } bzero(&decoder, sizeof(deco...
C
int main() { int a; a = 1+1-(1+1)*2/2; // = 0 printi(a); //0 printf("\n"); int b = 5; int c = a * (b + 1 + 1) + 1; // = 1 //int e = -d //erreur de syntaxe ';' /* test commentaire sur plusieurs lignes */ //int e = -d; //erreur sémantique sur d //int f = 0 / 0; //divisi...
C
// Prim Wandeevong // CS 135 // Lab 10 // 4-15-19 // #include <stdio.h> int main() { char str[21], vowels[21], consonants[21]; char *strPointer, *vowelPointer, *consonantPointer; printf("Enter a string (20 characters maximum): "); scanf("%s", str); strPointer = &str[0]; vowelPointer = &vowels[0]; consonantPo...
C
#include <stdio.h> #include <io.h> #include <stdint.h> #define BASE_ADDR ((volatile char*) 0x00011000) #define MSG00_TEST 0b0101010101010101010101010 0000000 #define MSG01_TEST 0b0110010011101000111100010 0000000 #define MSG02_TEST 0b01001110010111101110001110000000 #define MSG03_TEST 0b0001100110011001100110011 0000...
C
#include "holberton.h" #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> /** * write_error - prints out error for write * @file: input file * Return: void */ void write_error(const char *file) { dprintf(STDERR_FILENO, "Error: Can't write to ...
C
#include<stdio.h> #include "Util.h" void InsertNth(struct node** head, int ndx, int data) { if(ndx == 0) { Push(head, data); } else { int i = 0; struct node* cur = *head; for(i = 0; i < ndx -1; i++) { cur = cur->next; } if(cur != NULL) { Push(&(cur->next), data); } } } void main() { str...
C
/* Name: Paul Talaga Date: Jan 26, 2018 Desc: Does the power function. Compile this with the -lm flag at the end like: $ gcc pow.c -lm This includes the math library during the linking phase. */ #include <stdio.h> #include <math.h> int main(){ float base = 0.0; float exponent = 0.0; printf("Enter a base:\...
C
#include <stdio.h> #include <stdlib.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> int main(int argc, char const *argv[]) { FILE* fid; fid=fopen("/proc/device-tree/compatible","r"); if (fid==NULL) { printf("Problema al leer device-tree\n"); exit(-1); } printf("\nLey...
C
#include "head.h" int CheckMessage(user_t *usert) { FILE* cm; int nowmon = 0, nowday = 0; time_t t; struct tm *pt; lr_t lr; int subday = 0, retmon = 0, retday = 0; if ((cm = fopen(usert->name, "rb")) == NULL) { perror("fopen error"); Press getchar(); return -1; } time(&t); pt = localtime(&t); now...