language
large_stringclasses
1 value
text
stringlengths
9
2.95M
C
#ifndef _PLUGIN_API_H #define _PLUGIN_API_H #include <stdio.h> #include <getopt.h> #include <stdlib.h> #include <dirent.h> #include <string.h> #include <regex.h> #define PATTERN "^[0-9]{0,3}.[0-9]{0,3}.[0-9]{0,3}.[0-9]{0,3}$" /* Структура, описывающая опцию, поддерживаемую плагином. */ struct plugin_option { ...
C
/* * double_linked_list.c * * Created on: 19 Nov 2019 * Author: billy */ #include "double_linked_list.h" #include "streams.h" DoubleListNode *AllocateDoubleListNode (const double64 value) { DoubleListNode *node_p = (DoubleListNode *) AllocMemory (sizeof (DoubleListNode)); if (node_p) { InitListIte...
C
#include <stdarg.h> // varargs.h has been deprecated #include <stdio.h> // https://en.wikipedia.org/wiki/Variadic_function // passing number of variable arguments 'count' is possible idiom // but not at all enforced by the language double average(int count, ...) { va_list ap; // variable arguments list int j; ...
C
/* * Jacopo Del Granchio * #047 26.11.2019 * * Figura composta. */ #include <stdlib.h> #include <stdio.h> #include <math.h> #include <locale.h> #include <stdarg.h> // Prototipi void chiedi(char *, char *, ...); // Funzioni int main() { setlocale(LC_ALL, ""); float a, b, r; chiedi("Inserisci la base del ...
C
/** \file \brief Declaration of external system states. \details This files contain extern declaration and definition of static state structs for all external states. External states mean that these states might be requested from the system. Consequently, if any states are to be output from the system, they sho...
C
/** * crypter.h * * Author : Ourdia Oualiken and Jérémy LAMBERT * Date : 08/11/2017 * Description : functions needed for encryption / decryption */ #ifndef CRYPTER_H_ #define CRYPTER_H_ typedef struct message { int length; unsigned char* array; } message_t; /** * Returns the value of the nth bit of the ...
C
/*! * @file main.c * @brief Hall Current 16 Click example * * # Description * This example demonstrates the use of Hall Current 16 click board * by reading and displaying the current measurements. * * The demo application is composed of two sections : * * ## Application Init * The initialization of SPI modu...
C
/* server setup */ #include<stdio.h> #include<sys/types.h> #include<sys/socket.h> #include<netinet/in.h> #include <arpa/inet.h> #include<stdlib.h> #include<netdb.h> #include<string.h> #include"cserver.h" struct SPeer { char PID[2]; char PADDRESS[20]; char PNUM[7]; }peers[10]; static int peerCo...
C
/* ============================================================================ Name : tp_2.c Author : Bianca Gimenez Version : Copyright : Your copyright notice Description : Hello World in C, Ansi-style ============================================================================ */ #include...
C
/** * Because of stupid trimpots */ #include <avr/io.h> #include <avr/sleep.h> #include <avr/interrupt.h> #include <util/delay.h> #include "../iocompat.h" // Frequency adjustment, results in ~25kHz PWM. #define FREQ_ADJ 160 #define PWM_MAX 0.9*FREQ_ADJ // Max PWM (of 255) allowed for fan = 90% #define PWM_MIN ...
C
/* ** EPITECH PROJECT, 2021 ** exec_unsetenv.c ** File description: ** exec_unsetenv.c */ #include "c_functions.h" #include "mysh.h" #include "mysh_macros.h" #include "mysh_structures.h" int error_handling_unsetenv(char **command) { if (my_str_arr_length(command) == 1) { my_putstr(UNSETENV_TOO_FEW); ...
C
#include "header_files/SHT/SHT.h" #define FILENAME "hash_file.txt" #define SECONDARY_FILENAME "secondary_hash_file.txt" int main(void) { HT_info *info; BF_Init(); if ((HT_CreateIndex(FILENAME, 'i', "id", sizeof(int), 6)) < 0) { fprintf(stderr, "[!] Error in creating hash_file in main()\n"); return -...
C
#ifndef FUNCIONES_H_INCLUDED #define FUNCIONES_H_INCLUDED struct fecha{ int dia; int mes; int anio; }; struct paciente{ int dni; char nombre[30]; char apellido[30]; char genero; fecha f; int obrasocial; bool estado; }; ///|||||||||||||||||||||||||||||||||||||||||||||||||||||...
C
#include <stdio.h> #include<stdlib.h> int main(void){ int tamanho = 100; int posicao[tamanho]; int i; int soma = 0; int media = 0; for(i = 0; i<tamanho; i++){ printf("Digite o %d. valor: ", i+1); scanf("\n%d", &posicao[i]); } for(i = 0; i<tamanho; i++){ soma = soma + posica...
C
/* Problem 7: For loop in C. Easy Approach: Steps: 1) Take two integer inputs and apply for loop through the values. eg- input of a and b. make loop for (a to b) in which b is also included(Hint. use <= for b). 2) With the help of if-else statements check values upto 9. 3) later on check...
C
/** * Define a macro swap(t, x, y) that interchanges two arguments of type t. * (Block structure will help) */ #include <stdio.h> #define swap(t, x, y) { t temp; temp = x, x = y, y = temp; } int main() { int x = 1; int y = 2; swap(int, x, y); printf("x: %i\ny: %i\n", x, y); }
C
#ifndef lint static char sccsid[] = "%W% %G% %U%"; #endif #include <stdio.h> #include <stdlib.h> #include <string.h> /************************************************************************/ /* getenv_lf: */ /* Get the value of an environment variable as a double. */ /* Return 1 on success, 0 on failure. ...
C
#include <stdio.h> media(){ float x,y,z; float peso1,peso2,peso3; scanf("%f %f %f",&x,&y,&z); scanf("%f %f %f",&peso1,&peso2,&peso3); float media; media=(x*peso1+y*peso2+z*peso3)/(peso1+peso2+peso3); printf("A media final foi:%f\n",media); } main(){ media(); }
C
int myMax(int i, int j){ if(i >= j) return i; else return j; }
C
int bitwiseComplement(int N) { int c = 1; while (c < N) { c = (c << 1) | 1; printf("%d\n",c); } return N ^ c; } int bitwiseComplement(int N) { int m = 1; while (m < N) { m = m << 1 | 1; } return N ^ m; } /** C++ class Solution { public: int bitwiseComplemen...
C
#include <stdio.h> #include <stdlib.h> typedef struct grafo { int n; /* N�mero de n�s */ int **mat; /* Matriz (a ser alocada dinamicamente) */ } Grafo; void cria_grafo(Grafo* g, int n) { g->n = n; g->mat = malloc(n * sizeof (int)); for (int i = 0; i < n; ++i) g->mat[i] = calloc(n, size...
C
/* Week 2 Assignment 2 John McCormack */ #include <stdio.h> #include <limits.h> void main(void) { int counter = 1, largest = INT_MIN, number = 0; // largest_number value set to lowest possible value for INT printf("Please Enter 10 numbers. At the end the largest will be displayed\n"); while(counter...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <pthread.h> #include <time.h> #include <unistd.h> #include <math.h> int **Matrix; int FirstRow,FirstColumn,SecondRow,SecondColumn,TotalRow,TotalColumn; int i,Row,Column; int **FirstMatrix; int **SecondMatrix; int **Multip...
C
#include "queue.h" #include "type.h" int main(){ // print_function = print_type; // Queue queue = new_queue_with_type(getType()); // push(queue, new_item( new_type(1) )); // push(queue, new_item( new_type(2) )); // push(queue, new_item( new_type(3) )); // push(queue, new_item( ne...
C
#include "monitor-info-restaurantes.h" /* * t_dictionary: * <char* restaurante, t_info_restaurante info> */ t_dictionary* info_restaurantes; pthread_mutex_t mutex; void monitor_info_restaurantes_init(){ info_restaurantes = dictionary_create(); pthread_mutex_init(&mutex, NULL); } void monitor_info_restaurantes...
C
/** * project: 163 final project * * Conner Short * CMPE 163 * December 2017 * * sim.c: Simulation control functions **/ #include <stdio.h> #include <stdlib.h> #include <time.h> #include "sim.h" struct timed_func_node { void (*function_ptr)(); double tick_rate; double interp_factor; int persistent; struct...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include "computeFlux.h" #include "macroDefinition.h" #include "updateFlux.h" #include "visual.h" #include "computeTimeStep.h" void printMatrixf(int n_grid, double *matrix) { for (int x = 0; x < n_grid; ++x) { for (int y = 0; y < n_grid; ++y) { printf(...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include<float.h> #include<time.h> #include <stdint.h> int main(){ int real1, real2, img1, img2, soma1, soma2; printf("Digite a parte real"); scanf("%d", &real1); printf("Digite a parte img"); scanf("%d", &img1); printf("Digite a parte real2"); scanf("%d"...
C
#include <stdio.h> #include <stdlib.h> #include <math.h> #include "funcoes.c" int main() { float metros; printf("insira a medida em metros!\n"); scanf("%f",&metros); printf("%.2f metros equivale a:\n",metros); metros=convert(metros); printf("%.2f dm\n",metros); metros=convert(metros); ...
C
// pi.c #include <stdlib.h> #include <stdio.h> double f( double x ) { return 4.0 / ( 1 + x*x ); } int main( int argc, char *argv[] ) { int N, i; double deltaX, sum; if ( argc < 2 ) { printf( "Syntax %s N\n", argv[0] ); exit(1); } N = atoi( argv[1] ); sum = 0; deltaX = ...
C
#include <stdio.h> #include "search.h" #include <stdlib.h> int check_uniq(FILE *fp , int roll_no){ //Accepting file pointer and roll no as parameters char namef[1000] , namel[1000] , date[20], category[30] ,BUFFER[1000]; int *roll , *fees; roll = (int *)malloc(sizeof(int)); fees = (int *)malloc(sizeof(int)); ...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <fcntl.h> int main(int argc, char* argv[]) { int fd = 0; fd = open("Hello.txt", O_WRONLY); if(fork() == 0) { write(fd, "Child", 5); } else { write(fd, "Parent", 6); } exit(0); }
C
#include<stdio.h> int main(){ int idade; float peso, altura, imc; printf("\nDigite sua idade\n"); scanf("%d", &idade); printf("\nDigite seu peso em quilos (separando com ponto)\n"); scanf("%f", &peso); printf("\nDigite sua altura em metros (separando com ponto)\n"); scanf("%f", &altura); imc = pe...
C
/* * Copyright (C) 2014 Soul Trace <S-trace@list.ru> * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published * by the Free Software Foundation. * */ #define _POSIX_SOURCE #define _POSIX_C_SOURCE 199309L /* getopt */ #...
C
##include <stdio.h> #include <stdlib.h> int main() { int number, result=0; char cymbol=65; printf("Enter number:"); scanf("%d", &number); while (!result) { result=number/12*10+number%12; if (number%12==10) printf("%d%c", number/12, cymbol); else if (number%12...
C
/* *定义一个函数,得到数组的最大值,要求函数的返回值一定是void * */ #include <stdio.h> void maxarr(int *p, int n, int *max) { int i; //*p--->*(p+0) --->p[0] *max = p[0]; for (i = 1; i < n; i++) { if (*(p+i) /*p[i]*/ > *max) *max = p[i]; } } int main(void) { int arr[10] = {1,5,2,9,4,10,17,1,2,3}; int m; maxarr(arr, 10, &m); pr...
C
#include <stdio.h> #include <string.h> #include <SDL2/SDL.h> #include <SDL2/SDL_image.h> #include <SDL2/SDL_ttf.h> #include "error.h" #include "graphics.h" #include "input.h" // Blit a button on the main screen surface int blit_button(struct s_context *cxt, const char *path, SDL_Rect pos, const char * text, const cha...
C
#include <stdio.h> int main(void) { int a,b,c; printf("enter the minutes"); scanf("%d",&a); b=a/60; c=a%60; printf("\n the time is %d hours and%d minutes",b,c); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> // Armazenar na matrix e imprimir valores. off_t fsize(const char *filename) { struct stat st; if (stat(filename, &st) == 0) return st.st_size; return -1; } int argOk(const char **argv) { if (argv[1] == 0) { printf("...
C
#include <stdio.h> int x; void leia () { printf("Digite um numero"); scanf ("%d",&x); } void imprime () { printf("o antecessor e: %d\n",x - 1); printf("o sucessor e:%d\n",x + 1); ; } int main() { leia(); imprime(); return 0; }
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #define FILE_NAME "queue.txt" #include <limits.h> // A structure to represent a queue typedef struct Queue { int front, rear, size; unsigned capacity; int* array; } Queue; // function to create a queue // of given capacity. // It initializes size of queu...
C
#include "physbot.h" #include "quadratic.h" #include "../physics.h" #include "../dr.h" #include "../cvxgen/solver.h" #include <math.h> // Angles of each wheel relative to the front of the bot. // TODO: these should actually be measured. const float rel_wheel_angles[4] = { 30, 120, -30, -120 }; void build_M_matrix(Phy...
C
//To read a sorted array and search for an element using binary search #include <stdio.h> #include <conio.h> int main() { int a[30],n,i,t,low,mid,high,found=0; printf("Enter the number of elements:"); scanf("%d",&n); printf("\n Enter the elements of the array:"); for(i=0;i<n;i++) scanf("%d",&a[i]); ...
C
#include "oh/computer/system.h" #include "oh/external/external.h" struct oh_computer_system_t { unsigned long order; oh_computer_logic_f logic; oh_computer_output_t *computations; }; static void compute_with_logic(oh_computer_system_t *system); static void free_computations(oh_computer_system_t *system); stat...
C
#include <stdio.h> #include <stdlib.h> int main() { float exorcismProcess=0.2; int flyNumber; float exorcismSpeed=5; float fatigueTime=5; float flyReturnSpeed=3; int exorcismTime=0; float flyResidue; printf("Vvedite chislo myh:"); scanf("%d", &flyNumber); while (flyNumber>0) ...
C
/*-- Copyright (c) 1996-1997 Microsoft Corporation Module Name: dacls.c Abstract: Extended version of cacls.exe Author: 14-Dec-1996 (macm) Environment: User mode only. Requires ANSI C extensions: slash-slash comments, long external names. Revision History: --*/ ...
C
#ifndef STRUKTURY_H #define STRUKTURY_H #define MAX_BUFOR 1024 #define MAX_SKOK 2 #define DZIELNIK 4 #define dPlot_Plot8 DPlot_Plot8 #pragma comment(lib, "Ws2_32.lib") /*Struktura VOL zawierajca dane dotyczce objtoci zbiornika*/ struct VOL { float Czas[MAX_BUFOR]; double Wartosc[MAX_BUFOR]; } Objetosc; /*Struktura ...
C
#include <stdio.h> int main() { int pulo, i,cano[101],n,score; scanf("%d %d", &pulo,&n); score = 0; for(i = 1; i<n+1; i++){ scanf("%d", &cano[i]); } for(i= 1; i<n; i++){ if( (cano[i] - cano[i+1] <= pulo) && (cano[i+1] - cano[i] <= pulo)) { score++; ...
C
#include "Common.h" status_t getPath(path_t** path, node_t* file) { node_t* node = cur; if (file) node = file; while (node) { if (pushIntoPath(path, node) == FAIL) { printf("ERROR: unable to add node into path.\n"); return FAIL; } node = node->parent; } return SUCCESS; } status_t pushIntoPath(path...
C
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <arpa/inet.h> #include <sys/wait.h> #include <signal.h> #define PORT "3490" //Port users will connect to #define BACKLOG ...
C
//限速是通过使进程睡眠实现的,设置一个定时器计算当前的速度, //如果发现大于限定的速度,那么就通过: //睡眠时间 = (当前传输速度 / 最大传输速度-1) * 当前传输时间来计算。 void limit_rate(session_t *sess, int bytes_transfered, int is_upload) { sess->data_process = 1; // 睡眠时间 = (当前传输速度 / 最大传输速度 – 1) * 当前传输时间; long curr_sec = get_time_sec(); long curr_usec = get_time_usec(); ...
C
#include "proc_signal.h" #include "errhandler.h" #include <stdlib.h> #include <signal.h> #if 1 handler_t* Signal(int signum, handler_t* handler) { struct sigaction action, old_action; action.sa_handler = handler; sigemptyset(&action.sa_mask); /* Block sigs of type being handled */ ...
C
#include <stdio.h> int main(int argc, char *argv[]) { if (argc != 2) { fprintf(stderr, "Usage: ./recover 'name of a forensic image yo recover JPEGs'\n" ); return 1; } char *fi = argv[1]; FILE *inptr = fopen("card.raw", "r"); if (inptr == NULL) { fprintf(stderr, "Coul...
C
#pragma once /*! * \brief Use this to change the Default Settings for each component. Loaded when the Arduino starts, updated by user interaction on the website. * \details The Settings object is stored in EEPROM and kept between reboots. * \author GrowBoxGuy * \version 4.20 * \warning Only us...
C
#include <stdio.h> float integral; float prev_error; void controller () { float set_point; float dt; float u; float error = set_point - y; integral += error * dt; float derivative = (error - prev_error) / dt; prev_error = error; u = Kp * error + Ki * integral + Kd * derivative; } int main () { i...
C
#include "holberton.h" #include "2-strlen.c" #include <stdlib.h> /** * str_concat - Entry point * @s1: String * @s2: String * * Description: Alocate memory adn concatenate 2 strings * Return: Pointer to resault */ char *str_concat(char *s1, char *s2) { int len1 = 0, len2 = 0, totlen = 0, i = 0, j = 0; char *dest; i...
C
//SOMEWHY IT DOESN'T WORK FOR PLAINTEXT: world!$? ..BUT SEEMS TO WORK FOR EVEYTHING ELSE... #include <cs50.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <ctype.h> int main(int argc, string argv[]) { // validity checking if (argc == 2 ) { int local = 0; for (int i =...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* data_list.c :+: :+: :+: ...
C
#include "common.h" #include "uart.h"//Don't use the UART! It disables my interrupts. #include "oc.h" #include "timer.h" #include "ui.h" #include <p24FJ128GB206.h> #include "pin.h" #include "keymap.h" #define MAX_OUTPUT 2^15 #define MOTOR_BASE_SPEED MAX_OUTPUT>>8 #define SERVO 8 #define KEYBOARD_CLOCK 12//green #def...
C
#include<stdio.h> #include<math.h> //#include<gsl_integration.h> #include<gsl/gsl_integration.h> double f(double x, void* params){ double func = (log(x)/sqrt(x)); return func; } double ing() { gsl_function F; F.function = &f; int limit = 999; gsl_integration_workspace* w = gsl_integration_workspace_...
C
#include <stdio.h> #include <stdlib.h> void test() { printf("cur func : %s ; cur line : %d\n", __FUNCTION__, __LINE__); return; } void main() { printf("cur file : %s ; cur func : %s ; cur line : %d\n", __FILE__, __FUNCTION__, __LINE__); test(); return; } /* $ a.exe cur file : 1.c ; cur func : m...
C
/** ***************************************************** @brief USB, USB Communication library functions @file com.c @author Alexander Borg @version 1.0 @date 29-November-2019 @brief Source code for USB communication ***************************************************** */ #include <usb.h> /** @brief usb_se...
C
/* * The expression that specifies the width of a bit-field shall be an integer * constant expression that has nonnegative value that shall not exceed the * number of bits in an object of the type that is specified if the colon and * expression are omitted. If the value is zero, the declaration shall have no ...
C
/*Caesar’s algorithm encrypts messages by "rotating" each letter by "k" positions. * If "p" is some plaintext, pi is the ith character in p, and k is a secret key (non-negative integer), then each letter, ci, in the ciphertext, c, is computed as ci=(pi+k)mod26 ci=(pi+k)mod26 wherein mod26 here means "...
C
// POS50-C: Compliant Solution (Allocated Storage) void *childThread(void *val) { /* Correctly prints 1 */ int *res = (int *)val; printf("Result: %d\n", *res); free(res); return NULL; } void createThread(pthread *tid) { int result; /* Copy data into dynamic memory */ int *val = malloc(sizeof(int)); ...
C
#include "tinyfx.h" #include <stdio.h> #include <SDL2/SDL.h> #include <assert.h> #include <sys/signal.h> #include <stdlib.h> #define INTERNAL_RES 240 void *read_file(const char *filename) { FILE *f = fopen(filename, "r"); if (f) { fseek(f, 0L, SEEK_END); int bytes = ftell(f); rewind(f); char *buf = malloc(b...
C
/* * Copyright (c) 2014-2015 André Erdmann <dywi@mailerd.de> * * Distributed under the terms of the MIT license. * (See LICENSE.MIT or http://opensource.org/licenses/MIT) */ #ifndef _COMMON_DYNSTR_H_ #define _COMMON_DYNSTR_H_ #include <stdlib.h> #include <sys/types.h> #ifndef DEFAULT_DYNSTR_SIZE enum { /** i...
C
//编写一段程序,像下面那样读取一个整数并显示该整数加上12之后的结果。 #include <stdio.h> int main(void){ int a; printf("输入一个整数:"); scanf("%d", &a); printf("整数加上12的结果是%d\n", 12 + a); return 0; }
C
//#include <stdio.h> //#include <stdlib.h> // ///* //creator: //time:2015/9/12 //place:xust //*/ // //#define _TYPE int //typedef struct _node //{ // _TYPE data;// // struct _node *next; //}listlink,*pzlistlink; // ////ʼ //pzlistlink Initlistlink() //{ // pzlistlink head; // if(!(head=(pzlistlink)malloc(sizeof(pzli...
C
#include <stdio.h> #include <sys/resource.h> #include<unistd.h> int main() { int i=1; pid_t child; child=fork(); for(i=1;;i++) { child=fork(); printf("child=%d/n",i); if(child<0) break; } printf("Total forked...
C
/** * code for sudoku functionality * Authors: Antony 1, Spring 5/27/2020 * */ #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> #include <time.h> #include "sudokustruct.h" #include "intpair.h" /* sudoku data structure */ typedef struct sudoku { int puzzle[9][9]; } sudoku_t; su...
C
#include "servidor.h" int main() { int id, status; id = msgget( IPC_KEY, IPC_CREAT | IPC_EXCL | 0666 ); exit_on_error(id, "Erro no msgget."); printf("Estou a usar a fila de mensagens id=%d\n", id); mensagem m; while(1) { status = msgrcv(id, &m, sizeof(m.conteudo), MSG_TYP, 0)...
C
#include <stdio.h> int main (void){ int x, y; while(scanf("%d %d", &x, &y) != EOF){ if(x>=y){ printf("%d\n", x-y); } if(x<y){ printf("%d\n", y-x); } } return 0; }
C
#include <stdio.h> int main(){ printf("a=%d ; b=%d ; c=%d ; d=%d ; e=%d ; f=%d ; g=%d ; h=%d\n", 1, 2, 3, 4, 5, 6, 7, 8) ; return 0; };
C
#include<stdio.h> int a[100][100]; int min(int a,int b){ if(a>b) return b; return a; } void warshall(int a[][100],int n) { int i,j,k; for(k=1;k<=n;k++){ for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ a[i][j]=min(a[i][j],a[i][k]+a[k][j]); } } } printf("shortest paths are \n"); for(i=1;i<=n;i++){ for(j=...
C
#define _GNU_SOURCE #include <stdio.h> #include <string.h> #include <stddef.h> #include <stdlib.h> #include <unistd.h> #include <omp.h> #include "queue.h" #include "/home/fas/hpcprog/ahs3/cpsc424/utils/timing/timing.h" #define DEBUG 0 #define INF -1 typedef struct s_adj_node{ int vertex; int weight; struct s_...
C
/// ===================================================================================== /// /// Filename: ejson.h /// /// Description: a easier way to handle json, you can also using it as a simple dic /// /// 1. we using list and dict to handle items in list and obj /// 2. we reco...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "ListyString.h" // Name: Ahmed Mansour // NID: ah505081 // This function reads an file and performs actions on a string. int processInputFile(char *filename) { ListyString *listy = malloc(sizeof(ListyString)); char *str = malloc(sizeof(char) * 1024)...
C
#ifndef CLIENT_H #define CLIENT_H /* Macros compativeis com o ADT tree */ #define Item2 Client #define Key2 long int #define key2(A) A->ref #define less2(A, B) key2(A) < key2(B) #define deleteItem2 free #define NULLitem2 NULL /** * Estrutura client - Representa um cliente de referencia/chave ref. Emitiu * nche cheq...
C
#include <stdio.h> /* 6. Faça um algoritmo que leia um caractere e informe se o mesmo é uma vogal ou não */ main () { char letra; printf("\ninforme um caracter: "); scanf(" %c",&letra); switch(letra) { case 'a': case 'e': case 'i': case 'o': case 'u': printf("\nSIM"); break; default: pri...
C
#include <xinu.h> // Returns the CPU Gross Time of a Proccess syscall getuptime() { // Disabe Interrupts intmask mask = disable(); // Get Current Process struct procent *prptr = &proctab[currpid]; // No Proc if(prptr->prstate == PR_FREE) { restore(mask); return SYSERR; } // Return Usage Time uint32 tim...
C
#include <stdarg.h> #include <stdio.h> #include "callinfo.h" int mlog(int pc, const char *fmt, ...) { static unsigned int id = 1; va_list ap; int res; res = fprintf(stderr, "[%04u] ", id++); if (pc) { char buf[16]; unsigned long long ofs; if (get_callinfo(&buf[0], sizeof(buf), &ofs) != -1) { ...
C
#include <string.h> #include <stdio.h> #include <stdlib.h> #include "../headers/config_reader.h" int init_str(char** str, int dim){ *str = malloc(sizeof(char)*dim); if(*str == NULL){ perror("config_reader: init_str"); return 0; } for(int i = 0; i < dim; i++){ (*str)[i] = 0; } return 1; } void free_str(char...
C
#include "lists.h" /** * is_palindrome - check if a singly linked list is a palindrome * @head: list to check * Return: 0 if not a palindrome 1 if it is */ int is_palindrome(listint_t **head) { listint_t *aux; int i, j[10000]; if (head == NULL) return (0); if (*head == NULL) return (1); aux = *head; for ...
C
#include <stdio.h> #include <stdlib.h> #include <string.h> #include "films.h" #include "utils.h" int main(int argc, char *argv[]) { if (argc != 3 && argc != 4) return ARG_ERR; if (strcmp(argv[2], "title") && strcmp(argv[2], "name") && strcmp(argv[2], "year")) return ARG_ERR; if (argc == 4...
C
#include <stdio.h> #include <string.h> int main(void){ FILE * fp; char nomEquip[100],nomEquipFitxer[100]; int trobat = 0; fp = fopen("lliga2007.txt","r"); if (fp == NULL){ printf("No s'ha pogut obrir el fitxer\n"); }else { printf("Diguem el nom del equip del que vols saber els gols.\n"); gets(nomEqu...
C
//Q8. WAP to find Factorial of a number [use for loop]. #include<stdio.h> void main() { int n,i; long fact; fact=1; printf("Enter a number : "); scanf("%d",&n); for(i=1;i<=n;i++) { fact*=i; } printf("\n Factorial = %d",fact); }
C
#include <stdio.h> #include <stdlib.h> #define MAX_LENGTH 256 // compte le nombre de ligne du fichier int countLines(FILE * filePointer){ int count = 0; char * stringBuffer = (char *) malloc( MAX_LENGTH ); while(!feof(filePointer)){ fgets(stringBuffer, MAX_LENGTH, filePointer); count++; ...
C
/* ** my_power_rec.c for in /home/marque_p/rendu/Piscine_C_J05 ** ** Made by Kamil Marque ** Login <marque_p@epitech.net> ** ** Started on Mon Oct 5 10:40:41 2015 Kamil Marque ** Last update Mon Oct 5 10:42:19 2015 Kamil Marque */ int my_power_rec(int nb, int power) { int res; res = nb; if (power == 0) ...
C
#include "filetools.h" int load_file_to_memory(const char *filename, char **buffer) { int size = 0; FILE *f = fopen(filename, "rb"); if (f == NULL) { *buffer = NULL; // -1 means file opening failed return -1; } // figure out the file size fseek(f, 0, SEEK_END); ...
C
#include <stdio.h> #include <stdlib.h> #include <conio.h> #include <windows.h> #include <math.h> #include "headfile.h" void num_find(struct student *head) { int num; char m; int j,flag=0; cyan printf("Ŀѧѧţ"); white scanf("%d",&num); fflush(stdin); struct student *headp,*...
C
/* Take input from the user and ask user to choose 0 for triangular star pattern and 1 for reversed triangular star pattern Then print the pattern accordingly * ** *** **** -> Triangular star pattern ***** **** *** ** * -> Reversed triangular star pattern */ #include <stdio.h> void starpattern(int rows); void squar(...
C
#include <stdio.h> #include <string.h> #include <stdlib.h> int index_of(char** names, int tam, char name[]){ for(int i = 0; i < tam; i++){ if(strcmp(names[i], name) == 0) return i; } return -1; } int main(){ int n, idC, in, pres, i, j, *saldo; char **names, cara[13]; scan...
C
//====================================================================== // f06.c / JAS // Tree of child processes with some zombies // In another terminal, execute command 'ps u' //---------------------------------------------------------------------- #include <stdio.h> #include <unistd.h> #include <sys/types.h> int m...
C
/* Copyright (C) 2016 RDA Technologies Limited and/or its affiliates("RDA"). * All rights reserved. * * This software is supplied "AS IS" without any warranties. * RDA assumes no responsibility or liability for the use of the software, * conveys no license or title under any patent, copyright, or mask work * right to t...
C
#include <stdio.h> int main() { float sb, sl, inss; printf("digite o valor do SB "); scanf("%f", &sb); if(sb <= 420) { inss = ( sb * 8 ) / 100; sl = sb - inss; printf("Valor do inss = %f , valor do salario liquido = %f", inss, sl); } if((sb > 420) && (sb < 135...
C
///////////////////////////////////////////////////////////////////////////////////////////////////// // Accept character from user and display its ASCII value in decimal, // octal and hexadecimal format. // Input : A // Output : Decimal 65 // Octal 0101 // Hexadecimal 0X41 // Author : Annaso Chavan ///////////////////...
C
#include "bubble.h" // Takes an array and the array size as inputs and sorts it in a Bubble Sort // method void Bubble_sort(int *arr, int size) { printf("Bubble Sort\n"); int moves = 0; int compares = 0; int j = 0; for (int i = 0; i <= size - 1; i++) { j = size - 1; while (j > i) { compares += 1...
C
/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* dirs_handling.c :+: :+: :+: ...
C
#include<stdio.h> void main() { int a=0,b=0; while(a<10) { if(a==5) { a=a+1; continue; }else{ printf("%d",a); b=b+1; a=a+1; } } }