vmware fedora 13 x86 server
$cat memory.c
#include <stdio.h>
#include <stdlib.h>
main()
{
char *memory;
int size=1024;
int m=0;
int i=0;
sleep(60);
while(1)
{
for(i=0;i<1024;i++){
memory = (char *)malloc(size);
if(memory == NULL) exit(-1);
sprintf(memory, "i love memoney!\n");
}
Hi,
I have a question which has probable been asked a few times previously on the internet, but I couldn't get a final answer anywhere.
My question is, If I run malloc inside an infinite while loop, when will it crash ?
Code:
#include <stdio.h>
#include <malloc.h>
int iteration = 0;
char* p;
int main(void)
{
while(1)
{
p = malloc(1024 * 1024 * 1
Guys, I have the following code
Code:
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/wait.h>
#include <unistd.h>
void read2();
main(int argc, char** argv)
{
int pid,status;
pid=fork();
if ( pid == 0 )
{
read2(argv[1], argv[2]);
Iam trying to execute a file that include many files but it seems my main copy.c can't read anyone of them
-----------------------------------------------------------------------------------------
Copy.c
Code:
#include <sys/stat.h>
#include <fcntl.h>
#include "tlpi_hdr.h"
#ifndef BUF_SIZE /* Allow "cc -D" to override definition */
#define BUF_SIZE 102
To start off with this is a homework assignment for my Operating Systems course and I am stumped.
The prof wants us to read in a source code file and take out all the comment lines and then output the file back into a new source code file.
I am getting an error that makes no sense.
Hi All,
I have written a C program to solve this problem but I am eager to know whether the same output can be obtained using sed or awk?
This is the input:
Code:
star
ferry
computer
symbol
prime
time
This is the output:
Code:
starferry
ferrycomputer
computersymbol
symbolprime
primetime
This is my code written in C.
Code:
#include<stdio.h>
#include<stdlib.h>
#includ
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
fork();
fork();
fork();
puts("hi");
return 0;
}
This program prints 8 times hi and exits,
Why? Is not each fork calls main recursively
as in:
f(): "hi"; f()
Hello,
I wrote this simple program which prints all the arguments given to a program.
My code is straightforward and this is it
Code:
#include <stdio.h>
#include <malloc.h>
int i = 0;
int main(int argc, char** argv)
{
printf("\nargc == [%d]",argc);
printf("\nthe arguments are ");
for(i=0;i<argc;i++)
{
printf(&q