You want to play with pipe/fork:#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
void work(void) {
int i;
for (i=0; i<512; i++) {
printf("Line %d\n", i);
}
}
int main(void) {
int pfds[2];
pid_t pid;
if (pipe(pfds) < 0) {
perror("pipe failed");
return EXIT_FAILURE;
}
pid = fork();
if (pid < 0) {
perror("fork failed&
Can you help me in finding out why this program is giving segmentation fault?
Code:
#include<stdio.h>
#include<string.h>
int main()
{
char a[10]={0,1,2,3,4,5,6,7,8,9};
printf("\n--%s-- unable to access values",a);
printf("\n--%d %d-- able to access through direct acess",a[2],a[3]);
printf("\n--%d-- but the failing to read the size\n",strlen(a));
return 0;
}
Code of baul :)
Code:
/*
* Hanx [Proyecto Fedora Peru] wth Code
* crc.c - app
*
* This program is private version, for anti-educational purposes and without any
* explicit or implicit warranty; in no event shall the author or
* contributors be liable for any direct, indirect or incidetal damages
hello
i have made a small program to find the md5 checksum of a string.i am using xshell to compile the program.
Code:
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <md5.h>
int main(int argc, char * argv) {
MD5_CTX context;
i write .....
Code:
#include <stdio.h>
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>
#define RUNNING_DIR "/tmp"
#define LOCK_FILE "exampled.lock"
#define LOG_FILE "exampled.log"
void log_message(filename,message)
char *filename;
char *message;
{
FILE *logfile;
&
I have a problem with my code because it doesn't work as I want to.
Here's the code.
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int st, nd;
printf("Hello!\a");
getchar();
printf("I'm the manudo's (iMnd) multiplicator 2.0\n");
getchar();
system("clear"
Hello,
Code:
#include <stdio.h>
#include <string.h>
void main()
{
char tab[2]={"12"};
FILE *outfile;
char *outname = "/home/dir/";
printf("%s",strcat(outname,tab));
outfile = fopen(strcat(outname,tab), "w");
if (!outfile) {
printf("There was a problem opening %s for writing\n", outname);
}
else {
&n
#include <stdio.h>
#include <stdlib.h>
#include <linux/i2c-dev.h>
#include <fcntl.h>
void main()
{
int fd,i;
int addr = 0b10100000; // The I2C address of the ADC
char buf[10] = {0};
float data;
char channel;
if ((fd = open("/dev/i2c-4",O_RDWR | O_WRONLY | O_NDELAY )) < 0)
{
printf("Failed to open the bus.");
exit(1