SlideShare une entreprise Scribd logo
1  sur  13
UNIX and “C” For more info check out the Unix man pages (i.e., do “man -k topic-you-wish-to-search”)  -or- Unix in a Nutshell -and C Language Reference Manual (K&R). This document gives a starter in how to program in C.  There’s very little here that’s UNIX specific – all the functions described here will run on any operating system.
Remember printf? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What about Input? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
What are stdin, stdout, stderr? ,[object Object],[object Object],[object Object]
File I/O Operations ,[object Object],[object Object],[object Object],[object Object],[object Object]
fopen ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
fclose #include<stdio.h> #include<errno.h> void main() { FILE *myfile; if( NULL == (myfile = fopen( “myfile.txt”, “w”))) { perror(“fopen failed in main”); exit(-1); } fclose( myfile ); /* could check for error here, but usually not needed */ }
fscanf #include<stdio.h> #include<errno.h> void main() { FILE *myfile; int i, j, k; char buffer[80]; if( NULL == (myfile = fopen( “myfile.txt”, “w”))) { perror(“fopen failed in main”); exit(-1); } fscanf( myfile, “%d %d %d %s”, &i, &j, &k, buffer); fclose( myfile ); /* could check for error here, but usually not needed */ }
fprintf #include<stdio.h> #include<errno.h> void main() { FILE *myfile; int i, j, k; char buffer[80]; if( NULL == (myfile = fopen( “myfile.txt”, “w”))) { perror(“fopen failed in main”); exit(-1); } fscanf( myfile, “%d %d %d %s”, &i, &j, &k, buffer); fprintf( myfile, “%d %d %d %s, i, j, k, buffer ); fclose( myfile ); /* could check for error here, but usually not needed */ }
Pipes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
To send mail use “sendmail” ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Putting it all together with pipes #include<stdio.h> #include<errno.h> void main() { FILE *mailpipe; if( NULL == (mailpipe = popen( “usr/lib/sendmail -t”, “w”))) { perror(“popen failed in main”); exit(-1); } fprintf( mailpipe, “To: chrisc@cs.rpi.edu ” ); fprintf( mailpipe, “From: bogus ” ); fprintf( mailpipe, “Subject: test ” ); fprintf( mailpipe, “This is a test. ” ); fprintf( mailpipe, “.” ); pclose( mailpipe ); /* could check for error here, but usually not needed */ }
Other useful commands... ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]

Contenu connexe

Tendances

Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scriptingCorrado Santoro
 
Shell Scripts
Shell ScriptsShell Scripts
Shell ScriptsDr.Ravi
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell ScriptingRaghu nath
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsSudharsan S
 
Quick start bash script
Quick start   bash scriptQuick start   bash script
Quick start bash scriptSimon Su
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell ScriptingJaibeer Malik
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsDr.Ravi
 
Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaUnix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaiCreateWorld
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell ScriptingRaghu nath
 
Easiest way to start with Shell scripting
Easiest way to start with Shell scriptingEasiest way to start with Shell scripting
Easiest way to start with Shell scriptingAkshay Siwal
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filtersbhatvijetha
 

Tendances (20)

Introduction to shell scripting
Introduction to shell scriptingIntroduction to shell scripting
Introduction to shell scripting
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Shell Scripts
Shell ScriptsShell Scripts
Shell Scripts
 
Chap06
Chap06Chap06
Chap06
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Quick start bash script
Quick start   bash scriptQuick start   bash script
Quick start bash script
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Unix And Shell Scripting
Unix And Shell ScriptingUnix And Shell Scripting
Unix And Shell Scripting
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Unix lab manual
Unix lab manualUnix lab manual
Unix lab manual
 
Unix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU KarnatakaUnix 1st sem lab programs a - VTU Karnataka
Unix 1st sem lab programs a - VTU Karnataka
 
Unix - Shell Scripts
Unix - Shell ScriptsUnix - Shell Scripts
Unix - Shell Scripts
 
Unix shell scripting
Unix shell scriptingUnix shell scripting
Unix shell scripting
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Bash Shell Scripting
Bash Shell ScriptingBash Shell Scripting
Bash Shell Scripting
 
Unix shell scripts
Unix shell scriptsUnix shell scripts
Unix shell scripts
 
Easiest way to start with Shell scripting
Easiest way to start with Shell scriptingEasiest way to start with Shell scripting
Easiest way to start with Shell scripting
 
Linux shell scripting
Linux shell scriptingLinux shell scripting
Linux shell scripting
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filters
 

Similaire à Unix And C

Write a C program called pross-c to implement the UNIX-Linux equivalen.docx
Write a C program called pross-c to implement the UNIX-Linux equivalen.docxWrite a C program called pross-c to implement the UNIX-Linux equivalen.docx
Write a C program called pross-c to implement the UNIX-Linux equivalen.docxSUKHI5
 
C for Java programmers (part 1)
C for Java programmers (part 1)C for Java programmers (part 1)
C for Java programmers (part 1)Dmitry Zinoviev
 
OSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoOSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoChris McEniry
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionProf. Wim Van Criekinge
 
File handling-dutt
File handling-duttFile handling-dutt
File handling-duttAnil Dutt
 
C_and_C++_notes.pdf
C_and_C++_notes.pdfC_and_C++_notes.pdf
C_and_C++_notes.pdfTigabu Yaya
 
Rust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command LineRust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command LineMatt Provost
 
Hello. I was wondering if I could get some help on this C programmin.pdf
Hello. I was wondering if I could get some help on this C programmin.pdfHello. I was wondering if I could get some help on this C programmin.pdf
Hello. I was wondering if I could get some help on this C programmin.pdffashionfootwear1
 
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDYC UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDYRajeshkumar Reddy
 
11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.pptSIDDHARTHANANDCSE202
 
file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.pptyuvrajkeshri
 
C Under Linux
C Under LinuxC Under Linux
C Under Linuxmohan43u
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manualSami Said
 
Bash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageBash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageRené Ribaud
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basicsAbhay Sapru
 

Similaire à Unix And C (20)

Write a C program called pross-c to implement the UNIX-Linux equivalen.docx
Write a C program called pross-c to implement the UNIX-Linux equivalen.docxWrite a C program called pross-c to implement the UNIX-Linux equivalen.docx
Write a C program called pross-c to implement the UNIX-Linux equivalen.docx
 
Prog i
Prog iProg i
Prog i
 
C for Java programmers (part 1)
C for Java programmers (part 1)C for Java programmers (part 1)
C for Java programmers (part 1)
 
OSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with GoOSCON2014 : Quick Introduction to System Tools Programming with Go
OSCON2014 : Quick Introduction to System Tools Programming with Go
 
Bioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introductionBioinformatica 29-09-2011-p1-introduction
Bioinformatica 29-09-2011-p1-introduction
 
CInputOutput.ppt
CInputOutput.pptCInputOutput.ppt
CInputOutput.ppt
 
7.0 files and c input
7.0 files and c input7.0 files and c input
7.0 files and c input
 
File handling-dutt
File handling-duttFile handling-dutt
File handling-dutt
 
C_and_C++_notes.pdf
C_and_C++_notes.pdfC_and_C++_notes.pdf
C_and_C++_notes.pdf
 
Rust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command LineRust LDN 24 7 19 Oxidising the Command Line
Rust LDN 24 7 19 Oxidising the Command Line
 
Hello. I was wondering if I could get some help on this C programmin.pdf
Hello. I was wondering if I could get some help on this C programmin.pdfHello. I was wondering if I could get some help on this C programmin.pdf
Hello. I was wondering if I could get some help on this C programmin.pdf
 
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDYC UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
C UNIT-5 PREPARED BY M V BRAHMANANDA REDDY
 
11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt11_UNIX_Processes_Including_Select.ppt
11_UNIX_Processes_Including_Select.ppt
 
file_handling_in_c.ppt
file_handling_in_c.pptfile_handling_in_c.ppt
file_handling_in_c.ppt
 
C Under Linux
C Under LinuxC Under Linux
C Under Linux
 
Unit5
Unit5Unit5
Unit5
 
Python build your security tools.pdf
Python build your security tools.pdfPython build your security tools.pdf
Python build your security tools.pdf
 
Lex tool manual
Lex tool manualLex tool manual
Lex tool manual
 
Bash is not a second zone citizen programming language
Bash is not a second zone citizen programming languageBash is not a second zone citizen programming language
Bash is not a second zone citizen programming language
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 

Plus de Dr.Ravi

Corporate Overview
Corporate  OverviewCorporate  Overview
Corporate OverviewDr.Ravi
 
Excel For The Ceo
Excel For The CeoExcel For The Ceo
Excel For The CeoDr.Ravi
 
Project Specs Pf
Project Specs PfProject Specs Pf
Project Specs PfDr.Ravi
 
Assignments Programming Fundamentals
Assignments Programming FundamentalsAssignments Programming Fundamentals
Assignments Programming FundamentalsDr.Ravi
 
Hdd Chssc
Hdd ChsscHdd Chssc
Hdd ChsscDr.Ravi
 
Chssc Day3
Chssc Day3Chssc Day3
Chssc Day3Dr.Ravi
 
Chssc Day1
Chssc Day1Chssc Day1
Chssc Day1Dr.Ravi
 
Chssc Assignments
Chssc AssignmentsChssc Assignments
Chssc AssignmentsDr.Ravi
 
Chssc Day4
Chssc Day4Chssc Day4
Chssc Day4Dr.Ravi
 
Chssc Day2
Chssc Day2Chssc Day2
Chssc Day2Dr.Ravi
 
Unix Lec2
Unix Lec2Unix Lec2
Unix Lec2Dr.Ravi
 
Unix Book
Unix BookUnix Book
Unix BookDr.Ravi
 
Unix Basics 04sp
Unix Basics 04spUnix Basics 04sp
Unix Basics 04spDr.Ravi
 
Wicked Cool Shell Scripts
Wicked Cool Shell ScriptsWicked Cool Shell Scripts
Wicked Cool Shell ScriptsDr.Ravi
 
SAP INTRO
SAP INTROSAP INTRO
SAP INTRODr.Ravi
 

Plus de Dr.Ravi (18)

Corporate Overview
Corporate  OverviewCorporate  Overview
Corporate Overview
 
Excel For The Ceo
Excel For The CeoExcel For The Ceo
Excel For The Ceo
 
Project Specs Pf
Project Specs PfProject Specs Pf
Project Specs Pf
 
Pf Day5
Pf Day5Pf Day5
Pf Day5
 
Assignments Programming Fundamentals
Assignments Programming FundamentalsAssignments Programming Fundamentals
Assignments Programming Fundamentals
 
Hdd Chssc
Hdd ChsscHdd Chssc
Hdd Chssc
 
Chssc Day3
Chssc Day3Chssc Day3
Chssc Day3
 
Chssc Day1
Chssc Day1Chssc Day1
Chssc Day1
 
Pf Day3
Pf Day3Pf Day3
Pf Day3
 
Ldd Pf
Ldd PfLdd Pf
Ldd Pf
 
Chssc Assignments
Chssc AssignmentsChssc Assignments
Chssc Assignments
 
Chssc Day4
Chssc Day4Chssc Day4
Chssc Day4
 
Chssc Day2
Chssc Day2Chssc Day2
Chssc Day2
 
Unix Lec2
Unix Lec2Unix Lec2
Unix Lec2
 
Unix Book
Unix BookUnix Book
Unix Book
 
Unix Basics 04sp
Unix Basics 04spUnix Basics 04sp
Unix Basics 04sp
 
Wicked Cool Shell Scripts
Wicked Cool Shell ScriptsWicked Cool Shell Scripts
Wicked Cool Shell Scripts
 
SAP INTRO
SAP INTROSAP INTRO
SAP INTRO
 

Dernier

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Dernier (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Unix And C

  • 1. UNIX and “C” For more info check out the Unix man pages (i.e., do “man -k topic-you-wish-to-search”) -or- Unix in a Nutshell -and C Language Reference Manual (K&R). This document gives a starter in how to program in C. There’s very little here that’s UNIX specific – all the functions described here will run on any operating system.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7. fclose #include<stdio.h> #include<errno.h> void main() { FILE *myfile; if( NULL == (myfile = fopen( “myfile.txt”, “w”))) { perror(“fopen failed in main”); exit(-1); } fclose( myfile ); /* could check for error here, but usually not needed */ }
  • 8. fscanf #include<stdio.h> #include<errno.h> void main() { FILE *myfile; int i, j, k; char buffer[80]; if( NULL == (myfile = fopen( “myfile.txt”, “w”))) { perror(“fopen failed in main”); exit(-1); } fscanf( myfile, “%d %d %d %s”, &i, &j, &k, buffer); fclose( myfile ); /* could check for error here, but usually not needed */ }
  • 9. fprintf #include<stdio.h> #include<errno.h> void main() { FILE *myfile; int i, j, k; char buffer[80]; if( NULL == (myfile = fopen( “myfile.txt”, “w”))) { perror(“fopen failed in main”); exit(-1); } fscanf( myfile, “%d %d %d %s”, &i, &j, &k, buffer); fprintf( myfile, “%d %d %d %s, i, j, k, buffer ); fclose( myfile ); /* could check for error here, but usually not needed */ }
  • 10.
  • 11.
  • 12. Putting it all together with pipes #include<stdio.h> #include<errno.h> void main() { FILE *mailpipe; if( NULL == (mailpipe = popen( “usr/lib/sendmail -t”, “w”))) { perror(“popen failed in main”); exit(-1); } fprintf( mailpipe, “To: chrisc@cs.rpi.edu ” ); fprintf( mailpipe, “From: bogus ” ); fprintf( mailpipe, “Subject: test ” ); fprintf( mailpipe, “This is a test. ” ); fprintf( mailpipe, “.” ); pclose( mailpipe ); /* could check for error here, but usually not needed */ }
  • 13.