Skip to content

Instantly share code, notes, and snippets.

View mohamad-wael's full-sized avatar

mohamad wael mohamad-wael

View GitHub Profile
private void
player_started_play
( ){
int coordinates [ ] = null;
int machine_row_open_for_win = -1 ;
int machine_col_open_for_win = -1 ;
int player_row_open_for_win = -1 ;
int player_col_open_for_win = -1;
private void
machine_started_play
( ){
int coordinates [ ] = null;
int machine_row_open_for_win = -1 ;
int machine_col_open_for_win = -1 ;
if (turn_count == 1 )//machine is starting
coordinates = get_random_free_corner ( );
@mohamad-wael
mohamad-wael / tmpnam.c
Last active May 8, 2021 14:47
How to use the tmpnam function in c ?
#include <stdio.h>
#include <stdlib.h>
int
main
(int argc , char * argv [ ] ){
char tmp_path [L_tmpnam + 1 ];
@mohamad-wael
mohamad-wael / tmpfile.c
Created May 8, 2021 02:00
The C tmpfile function demo
#include <stdio.h>
#include <stdlib.h>
/* tmpfile function demo program . */
int
main
(int argc , char * argv [ ] ){
FILE * tmp = tmpfile ( );
@mohamad-wael
mohamad-wael / rename.c
Created May 7, 2021 22:19
How to rename a file in C .
#include <stdio.h>
#include <stdlib.h>
/* A simple program demonstrating the
C standard library , rename function .
The rename function can rename files
and directories .*/
int
main
(int argc , char * argv [ ] ){
@mohamad-wael
mohamad-wael / removeFile.c
Created May 7, 2021 20:51
How to remove files , using the stdio header in C .
#include <stdio.h>
#include <stdlib.h>
/* Program to remove files .
It can also remove empty directories
under linux , but directories
cannot be removed under windows .*/
int
main (int argc , char * argv [ ] ){
@mohamad-wael
mohamad-wael / file_copy.c
Created May 6, 2021 16:04
How to copy a file character by character in C ?
#include <stdio.h>
#include <stdlib.h>
/* Copy a file one character at a time .*/
int
main
(int argc , char * argv [ ] ){
if (argc != 3 ){
printf ("%s\n" , "Usage: fgp fom to" );
@mohamad-wael
mohamad-wael / for_loop_example_2.sh
Created April 28, 2021 16:12
shell for loop example
# Redirecting the output of a for
# loop to a file .
$ for x in {1..10} ; do echo $x ; done > filesave
$ cat filesave
1
2
3
4
@mohamad-wael
mohamad-wael / for_loop_example_1.sh
Created April 28, 2021 16:11
shell for loop example
$ c=1
$ echo $c
1
$ for c in {1..9}; do echo -n $c; done
123456789
# {1..9} will expand to 1 2 3 4 5 6 7 8 9 .
# The for loop will loop through these words ,
# and echo will echo the words . -n is used