Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6b81caa

Browse files
author
Safa Bayar
committed
quiz question and solve
1 parent feaef89 commit 6b81caa

File tree

15 files changed

+396
-0
lines changed

15 files changed

+396
-0
lines changed

‎Sonradan Yaptiklarim/c3.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include <stdio.h>
2+
#include <sys/types.h>
3+
#include <unistd.h>
4+
#include <sys/types.h>
5+
#include <sys/wait.h>
6+
7+
8+
int main(){
9+
10+
int ppid,status;
11+
if(ppid = fork()){
12+
printf("Hatasiz bir fork islemi\n");
13+
printf("benim pid'im : %d . Parent pid'i %d\n",getpid(),getppid());
14+
/* Burada kendi pid'si islemin olusturuldugu process id'si dir. Parent pid ise bash kabugunun pid'si dir. */
15+
16+
17+
if(ppid == 0){
18+
printf("Cocuk process (Child process) pid : %d\n",getpid());
19+
kill(getpid(),SIGINT);
20+
}else{
21+
printf("parent PID : %d . ppid degiskeni : %d\n",getppid(),ppid);
22+
wait(&status);
23+
printf("%s%s%s\n", WIFCONTINUED(status) ? " CONTINUED" : "", WIFSIGNALED(status) ? " SIGNALED" : "", WIFSTOPPED(status) ? " STOPPED" : "");
24+
}
25+
}
26+
27+
}

‎Sonradan Yaptiklarim/c3.c~

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <stdio.h>
2+
#include <sys/types.h>
3+
#include <unistd.h>
4+
5+
6+
int main(){
7+
8+
int ppid;
9+
if(ppid = fork()){
10+
printf("Hatasiz bir fork islemi\n");
11+
printf("benim pid'im : %d . Parent pid'i %d\n",getpid(),getppid());
12+
}
13+
14+
}

‎lab-7/#ornek_25_fork1.c#

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#include "apue.h"
2+
3+
int glob = 6; /* external variable in initialized data */
4+
char buf[] = "a write to stdout\n";
5+
6+
int main(void)
7+
{
8+
int var; /* automatic variable on the stack */
9+
pid_t pid;
10+
11+
var = 88;
12+
if (write(STDOUT_FILENO, buf, sizeof(buf)-1) != sizeof(buf)-1)
13+
err_sys("write error");
14+
printf("before fork\n"); /* we don't flush stdout */
15+
16+
if ((pid = fork()) < 0) {
17+
err_sys("fork error");
18+
} else if (pid == 0) { /* child */
19+
glob++; /* modify variables */
20+
var++;
21+
} else {
22+
sleep(2); /* parent */
23+
}
24+
25+
printf("pid = %d, glob = %d, var = %d\n", getpid(), glob, var);
26+
exit(0);
27+
}

‎lab-7/ornek_25_fork1.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include "apue.h"
2+
3+
int glob = 6; /* external variable in initialized data */
4+
char buf[] = "a write to stdout\n";
5+
6+
int
7+
main(void)
8+
{
9+
int var; /* automatic variable on the stack */
10+
pid_t pid;
11+
12+
var = 88;
13+
if (write(STDOUT_FILENO, buf, sizeof(buf)-1) != sizeof(buf)-1)
14+
err_sys("write error");
15+
printf("before fork\n"); /* we don't flush stdout */
16+
17+
if ((pid = fork()) < 0) {
18+
err_sys("fork error");
19+
} else if (pid == 0) { /* child */
20+
glob++; /* modify variables */
21+
var++;
22+
} else {
23+
sleep(2); /* parent */
24+
}
25+
26+
printf("pid = %d, glob = %d, var = %d\n", getpid(), glob, var);
27+
exit(0);
28+
}

‎quiz cozumlerim/safa-bayar-Sinav2/a.out

13.1 KB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
bu ikinci satir.
3+
bu dorduncu satir.
4+
Bu altinci satir.

‎quiz cozumlerim/safa-bayar-Sinav2/girdi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bu ilk satir.
2+
bu ikinci satir.
3+
bu ucuncu satir.
4+
bu dorduncu satir.
5+
bu besince satir.
6+
Bu altinci satir.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
b lk str.
2+
b knc str.
3+
b cnc str.
4+
b drdnc str.
5+
b bsnc str.
6+
B ltnc str.

‎quiz cozumlerim/safa-bayar-Sinav2/sinav

13.1 KB
Binary file not shown.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#include <stdio.h>
2+
3+
4+
int main(int argc,char * argv[]){
5+
6+
7+
char sesli[5] = {'a','e','i','u','o'};
8+
int temp=-1,c,i;
9+
char * buf[4096];
10+
11+
if(argc != 2){
12+
printf("Hatalı girdi sayısı ve dosya ismi\n");
13+
return 0;
14+
}
15+
FILE * girdi = fopen(argv[1],"r");
16+
FILE * ciftolan = fopen("cift_satirlar.txt","w");
17+
18+
while((c = getc(girdi)) != EOF){
19+
if(c == '\n'){
20+
temp += 1;
21+
}
22+
if(temp % 2 == 0){
23+
printf("%c",c);
24+
fputc(c,ciftolan);
25+
}
26+
}
27+
printf("\nSatır sayısı %d\n",temp);
28+
29+
fclose(ciftolan);
30+
fclose(girdi);
31+
32+
int c1 = 0;
33+
FILE * girdi1 = fopen(argv[1],"r");
34+
FILE * sesliolmayan = fopen("sesli_harfsiz.txt","w");
35+
while((c1 = getc(girdi1)) != EOF){
36+
37+
if(c1 != 'a' & c1 != 'e' & c1 != 'i' & c1 != 'u' & c1 != 'o'){
38+
printf("%c",c1);
39+
putc(c1,sesliolmayan);
40+
}
41+
42+
}
43+
44+
fclose(sesliolmayan);
45+
fclose(girdi1);
46+
47+
48+
return 0;
49+
50+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /