This document discusses C++ streams and stream classes. It explains that streams represent the flow of data in C++ programs and are controlled using classes. The key classes are istream for input, ostream for output, and fstream for file input/output. It provides examples of reading from and writing to files using fstream, and describes various stream manipulators like endl. The document also discusses the filebuf and streambuf base classes that perform low-level input/output operations.
This document provides an overview of file and stream input/output (I/O) in C++. It discusses how stream classes can be used to read from and write to files, with examples showing how to open files, write formatted data to files using output streams, and read data from files using input streams. Key classes for file I/O like ifstream, ofstream, and fstream are described. Techniques for handling different data types like characters, strings, and integers are also covered.
The document discusses file handling in C++. It covers:
1) Using input/output files by opening, reading from, and writing to files. Files are interpreted as sequences of bytes and can be text or binary.
2) General file I/O steps which include declaring a file name variable, associating it with a disk file, opening the file, using it, and closing it.
3) Predefined console streams like cin, cout, cerr, and clog which are used for standard input, output, error output, and buffered error output respectively.
The document discusses file handling in C++. It covers:
1) Using input/output files by opening, reading from, and writing to files using streams. Streams act as an interface between files and programs.
2) General file I/O steps which include declaring a file name variable, associating it with a disk file, opening the file, using it, and closing it.
3) Predefined console streams like cin, cout, cerr, and clog which are opened automatically and connected to the keyboard, display, and error output respectively.
This document discusses C++ file input/output (I/O) streams. It introduces the fstream, ifstream, and ofstream classes for reading from, writing to, and reading/writing files. It covers opening, reading from, writing to, closing, and handling both text and binary files sequentially and randomly using functions like get(), put(), getline(), read(), write(), seekg(), seekp(), tellg(), and tellp().
The document discusses file handling in C++. It explains that files store data permanently on storage devices and can be opened for input or output by programs. Streams act as an interface between files and programs, representing the flow of data. The predefined stream classes like ifstream, ofstream, and fstream allow reading from and writing to files. The document outlines the general steps to work with files, describes file modes and pointers, and provides examples of reading from and writing to both text and binary files in C++.
1. The document discusses file handling in C++, including opening and closing files, stream state member functions, and different types of file operations.
2. Key classes for file input/output in C++ include ifstream for reading files, ofstream for writing files, and fstream for reading and writing. These classes inherit from iostream and allow file access using insertion and extraction operators.
3. The document covers opening and closing files, checking for errors, reading and writing basic data types to files, binary file operations using read() and write(), and random access in files using seekp(), seekg(), and tellp(). It provides examples of reading from and writing to both text and binary files.
This document discusses C++ streams and stream classes. It explains that streams represent the flow of data in C++ programs and are controlled using classes. The key classes are istream for input, ostream for output, and fstream for file input/output. It provides examples of reading from and writing to files using fstream, and describes various stream manipulators like endl. The document also discusses the filebuf and streambuf base classes that perform low-level input/output operations.
This document provides an overview of file and stream input/output (I/O) in C++. It discusses how stream classes can be used to read from and write to files, with examples showing how to open files, write formatted data to files using output streams, and read data from files using input streams. Key classes for file I/O like ifstream, ofstream, and fstream are described. Techniques for handling different data types like characters, strings, and integers are also covered.
The document discusses file handling in C++. It covers:
1) Using input/output files by opening, reading from, and writing to files. Files are interpreted as sequences of bytes and can be text or binary.
2) General file I/O steps which include declaring a file name variable, associating it with a disk file, opening the file, using it, and closing it.
3) Predefined console streams like cin, cout, cerr, and clog which are used for standard input, output, error output, and buffered error output respectively.
The document discusses file handling in C++. It covers:
1) Using input/output files by opening, reading from, and writing to files using streams. Streams act as an interface between files and programs.
2) General file I/O steps which include declaring a file name variable, associating it with a disk file, opening the file, using it, and closing it.
3) Predefined console streams like cin, cout, cerr, and clog which are opened automatically and connected to the keyboard, display, and error output respectively.
This document discusses C++ file input/output (I/O) streams. It introduces the fstream, ifstream, and ofstream classes for reading from, writing to, and reading/writing files. It covers opening, reading from, writing to, closing, and handling both text and binary files sequentially and randomly using functions like get(), put(), getline(), read(), write(), seekg(), seekp(), tellg(), and tellp().
The document discusses file handling in C++. It explains that files store data permanently on storage devices and can be opened for input or output by programs. Streams act as an interface between files and programs, representing the flow of data. The predefined stream classes like ifstream, ofstream, and fstream allow reading from and writing to files. The document outlines the general steps to work with files, describes file modes and pointers, and provides examples of reading from and writing to both text and binary files in C++.
1. The document discusses file handling in C++, including opening and closing files, stream state member functions, and different types of file operations.
2. Key classes for file input/output in C++ include ifstream for reading files, ofstream for writing files, and fstream for reading and writing. These classes inherit from iostream and allow file access using insertion and extraction operators.
3. The document covers opening and closing files, checking for errors, reading and writing basic data types to files, binary file operations using read() and write(), and random access in files using seekp(), seekg(), and tellp(). It provides examples of reading from and writing to both text and binary files.
The document discusses files and streams in C++. It defines files as sequences of bytes that end with an end-of-file marker. Streams are used to connect programs to files for input and output. There are standard input and output streams (cin and cout) as well as file streams that use classes like ifstream for input and ofstream for output. Files can be accessed sequentially or randomly - sequential files are read from start to finish while random access files allow direct access to any record.
This document discusses C++ stream classes and file input/output. It covers the key stream classes like iostream, istream, ostream and their functions. It also discusses file classes like ifstream, ofstream and fstream that are used for file input/output. It provides examples of reading from and writing to files using these classes and their functions like open(), get(), put() etc. It mentions how file pointers are used to manipulate file positions for input/output operations.
Managing console i/o operation,working with filesramya marichamy
This document discusses C++ stream classes and file input/output. It covers the key stream classes like istream, ostream and iostream. It describes how to use stream manipulators and member functions to format console I/O. It also covers file streams like ifstream, ofstream and fstream for reading from and writing to files. Functions like open(), get(), put(), read(), write() are described for file I/O operations. Common file I/O tasks like displaying, modifying and deleting file contents are mentioned.
The document discusses file handling in C++. It describes how to perform input/output operations on files using streams. There are three types of streams - input streams, output streams, and input/output streams. Key functions for file handling include open(), close(), get(), getline(), read(), write(), tellg(), tellp(), seekg(), seekp(), and eof(). An example program demonstrates how to add, view, search, delete, and update records in a binary file using file handling functions.
Basic file operations in C++ involve opening, reading from, and writing to files. The key classes for input/output with files are ofstream for writing, ifstream for reading, and fstream for both reading and writing. A file must first be opened before performing any operations on it. Common operations include writing data to files with put() or write(), reading data from files with get() or read(), and closing files after completion. Proper opening modes and error handling should be used to ensure successful file input/output.
This document discusses file handling in C++. It begins by explaining that files allow data to be stored permanently on secondary storage devices like hard disks, unlike variables in memory. It then covers key topics like:
- The different types of files, such as text files containing readable characters and binary files containing raw data.
- Classes used for file input/output like ifstream, ofstream, and fstream.
- Opening, closing, reading from, and writing to files using functions like open(), close(), get(), put(), seekg(), tellg(), seekp(), and tellp().
- File pointers that track read/write positions and functions to manipulate them.
- Examples of creating
C++ - UNIT_-_V.pptx which contains details about File ConceptsANUSUYA S
The document discusses file handling in C++. It explains that files are used to store data permanently on a storage device. There are three main classes used for file handling - ifstream for input, ofstream for output, and fstream for both input and output. The key file handling operations include opening a file using open(), reading from a file using read(), writing to a file using write(), and closing a file using close(). It also discusses opening files in different modes, reading and writing binary data to files, and handling exceptions that may occur during file operations.
The document discusses file handling in C++. It explains that files are used to store data permanently on storage devices like hard disks, while variables are stored temporarily in memory. It then describes C++ streams and classes used for file input and output like ifstream, ofstream, and fstream. It also covers opening, closing, reading from and writing to files, as well as checking file pointers and seeking to different positions in a file.
Files provide a way to persistently store data on secondary storage like disks even when a computer is powered off. To use files, data is first written to a file from memory using functions like fopen(), fprintf(), fputs() which open, write to and close files. The data can later be read from the file into memory using functions like fopen(), fscanf(), fgets() when needed. Command line arguments passed when a program is executed are available in the main() function via argc and argv parameters, and can be accessed as strings and converted as needed using functions like sscanf().
This document discusses file input/output (I/O) in C++. It covers:
1) Stream classes like ifstream and ofstream that represent input/output data flows to files.
2) Formatted and binary I/O - formatted stores data as text which is inefficient for large numbers, while binary stores directly in memory format.
3) Reading and writing objects using binary I/O by casting object addresses and writing the full object size in bytes.
This document discusses files and streams in C++. It explains that the fstream library allows reading from and writing to files using ifstream, ofstream, and fstream objects. It covers opening, closing, writing to, and reading from files, noting that files must be opened before use and should be closed after. The standard openmode arguments and open(), close(), write, and read syntax are provided. Examples of reading from and writing to files are included.
The document discusses file input/output in C++. It covers the header file fstream.h, stream classes like ifstream and ofstream for file input/output, opening and closing files, reading/writing characters and objects to files, detecting end of file, moving file pointers for random access, and handling errors. Functions like open(), close(), get(), put(), read(), write(), seekg(), seekp(), tellg(), tellp(), eof(), fail(), bad(), good(), and clear() are described.
The document discusses file input/output in C++. It covers the header file fstream.h, stream classes like ifstream and ofstream for file input/output, opening and closing files, reading/writing characters and objects to files, detecting end of file, moving file pointers for random access, and handling errors. Functions like open(), close(), get(), put(), read(), write(), seekg(), seekp(), tellg(), tellp(), eof(), fail(), bad(), good(), and clear() are described.
The document discusses various C programming concepts like typedef, bitfields, enumeration, file I/O, text files vs binary files. typedef allows defining a new name for an already defined datatype. Bitfields allow packing structure members efficiently using bits. Enumeration defines a set of named integer constants. File I/O functions like fopen, fclose, fread, fwrite are used to read and write data to files. Text files contain human readable characters while binary files store data as bytes.
At the end of this lecture students should be able to;
Define the C standard functions for managing file input output.
Apply taught concepts for writing programs.
CS 23001 Computer Science II Data Structures & AbstractionPro.docxfaithxdunce63732
CS 23001 Computer Science II: Data Structures & Abstraction
Project #4
Spring 2015
Objectives:
· Develop and use a Tree ADT (n-ary)
· Apply and use tree traversal algorithms
· Manipulate trees by inserting and deleting nodes
· Apply and use STL
Problem:
Build a program profiler. Construct a program to instrument C++ source code to support program profiling.
It is often important to determine how many times a function or statement is executed. This is useful not only for debugging but for determining what parts of a program may need to be optimized. This process is called profiling. That is, a execution profile presents how many times each part of a program is executed using a given set of input data (or for some run time scenario). To compute a profile, statements need to be added to the code that keep track of how many times a function or statement is executed. The process of adding these statements is called instrumenting the code.
To implement a profiler one must first parse the source code and generate an Abstract Syntax Tree (AST) of the code. Each node of the AST describes the syntactic category of the code stored within it (function, statement, while-statement, etc.). So at the top level is a syntactic category corresponding to a program, class, or function (such as in the case of a main). Under that are sub-trees that further detail the syntactic categories of each part of the code. Such things as declarations, parameter lists, while-statement, and expression statements will describe the various parts of the program.
After the AST is generated it can then be traversed and the appropriate syntactic structures can be found that need to be instrumented. Once a construct is found, say a function, new code can be inserted that keeps track of how many times that function is executed.
The most difficult part of constructing a profiler is correctly parsing the source code. Unfortunately, C++ is notoriously difficult to parse. So here we will use a parsing tool called src2srcml. This tool reads in C++ code and marks up the code with XML tags (e.g., block, if, while, condition, name, etc). That is, the output is an AST in XML. The XML representation is called srcML (source code markup language).
A number of srcML data files are provided for the project. However, you can use your own program as input. To run srcML on wasp or hornet you will first need to set a PATH variable so the command can be found. You need to execute the command:
export PATH=/local/opt/srcml/bin:$PATH
It is best if you insert this line into your .bash_profile file in your home directory on wasp/hornet.
Then to generate the srcML file for your own code use the following:
src2srcml main.cpp -o main.cpp.xml
Use the following for a list of all options:
src2srcml --help
More information about srcML can be found at www.srcML.org including a list of all the tag names (see Getting Started). You can also download srcML if you want it on your own machine.
Your .
This document discusses file handling in C++. It covers key concepts like opening and closing files, reading from and writing to files, and different file access methods like sequential and random access. The document outlines the steps to handle files which include declaring a file name variable, associating it with a disk file, opening the file, using file input/output functions to read and write, and then closing the file. Common file handling functions like open(), close(), get(), put(), read(), and write() are also explained.
This document discusses file handling in C++. It explains that file handling allows storing data permanently on a computer's hard disk. The key steps for file handling are naming a file, opening it, writing data, reading data, and closing the file. It also discusses various file handling functions like fstream, ifstream, ofstream and their usage for opening, reading, writing and closing files. Functions like get(), put(), tellg(), seekg() and their usage with file streams are explained. Examples are provided to demonstrate reading from and writing to files.
This document discusses working with files in C++. It covers opening and closing files using constructors and the open() function. It describes using input and output streams to read from and write to files. It also discusses the different file stream classes like ifstream, ofstream, and fstream and their functions. Finally, it mentions the different file opening modes that can be used with the open() function.
Basics of files and its functions with exampleSunil Patel
The document discusses input/output files in C++. It covers key concepts like streams, predefined console streams, file modes, and file pointers. Binary file operations like get(), put(), read(), write(), and flush() are also summarized for reading and writing bytes from files. The main steps for file I/O in C++ are to declare a file name variable, associate it with a disk file, open the file, use the file for input/output, and close the file.
The document discusses files and streams in C++. It defines files as sequences of bytes that end with an end-of-file marker. Streams are used to connect programs to files for input and output. There are standard input and output streams (cin and cout) as well as file streams that use classes like ifstream for input and ofstream for output. Files can be accessed sequentially or randomly - sequential files are read from start to finish while random access files allow direct access to any record.
This document discusses C++ stream classes and file input/output. It covers the key stream classes like iostream, istream, ostream and their functions. It also discusses file classes like ifstream, ofstream and fstream that are used for file input/output. It provides examples of reading from and writing to files using these classes and their functions like open(), get(), put() etc. It mentions how file pointers are used to manipulate file positions for input/output operations.
Managing console i/o operation,working with filesramya marichamy
This document discusses C++ stream classes and file input/output. It covers the key stream classes like istream, ostream and iostream. It describes how to use stream manipulators and member functions to format console I/O. It also covers file streams like ifstream, ofstream and fstream for reading from and writing to files. Functions like open(), get(), put(), read(), write() are described for file I/O operations. Common file I/O tasks like displaying, modifying and deleting file contents are mentioned.
The document discusses file handling in C++. It describes how to perform input/output operations on files using streams. There are three types of streams - input streams, output streams, and input/output streams. Key functions for file handling include open(), close(), get(), getline(), read(), write(), tellg(), tellp(), seekg(), seekp(), and eof(). An example program demonstrates how to add, view, search, delete, and update records in a binary file using file handling functions.
Basic file operations in C++ involve opening, reading from, and writing to files. The key classes for input/output with files are ofstream for writing, ifstream for reading, and fstream for both reading and writing. A file must first be opened before performing any operations on it. Common operations include writing data to files with put() or write(), reading data from files with get() or read(), and closing files after completion. Proper opening modes and error handling should be used to ensure successful file input/output.
This document discusses file handling in C++. It begins by explaining that files allow data to be stored permanently on secondary storage devices like hard disks, unlike variables in memory. It then covers key topics like:
- The different types of files, such as text files containing readable characters and binary files containing raw data.
- Classes used for file input/output like ifstream, ofstream, and fstream.
- Opening, closing, reading from, and writing to files using functions like open(), close(), get(), put(), seekg(), tellg(), seekp(), and tellp().
- File pointers that track read/write positions and functions to manipulate them.
- Examples of creating
C++ - UNIT_-_V.pptx which contains details about File ConceptsANUSUYA S
The document discusses file handling in C++. It explains that files are used to store data permanently on a storage device. There are three main classes used for file handling - ifstream for input, ofstream for output, and fstream for both input and output. The key file handling operations include opening a file using open(), reading from a file using read(), writing to a file using write(), and closing a file using close(). It also discusses opening files in different modes, reading and writing binary data to files, and handling exceptions that may occur during file operations.
The document discusses file handling in C++. It explains that files are used to store data permanently on storage devices like hard disks, while variables are stored temporarily in memory. It then describes C++ streams and classes used for file input and output like ifstream, ofstream, and fstream. It also covers opening, closing, reading from and writing to files, as well as checking file pointers and seeking to different positions in a file.
Files provide a way to persistently store data on secondary storage like disks even when a computer is powered off. To use files, data is first written to a file from memory using functions like fopen(), fprintf(), fputs() which open, write to and close files. The data can later be read from the file into memory using functions like fopen(), fscanf(), fgets() when needed. Command line arguments passed when a program is executed are available in the main() function via argc and argv parameters, and can be accessed as strings and converted as needed using functions like sscanf().
This document discusses file input/output (I/O) in C++. It covers:
1) Stream classes like ifstream and ofstream that represent input/output data flows to files.
2) Formatted and binary I/O - formatted stores data as text which is inefficient for large numbers, while binary stores directly in memory format.
3) Reading and writing objects using binary I/O by casting object addresses and writing the full object size in bytes.
This document discusses files and streams in C++. It explains that the fstream library allows reading from and writing to files using ifstream, ofstream, and fstream objects. It covers opening, closing, writing to, and reading from files, noting that files must be opened before use and should be closed after. The standard openmode arguments and open(), close(), write, and read syntax are provided. Examples of reading from and writing to files are included.
The document discusses file input/output in C++. It covers the header file fstream.h, stream classes like ifstream and ofstream for file input/output, opening and closing files, reading/writing characters and objects to files, detecting end of file, moving file pointers for random access, and handling errors. Functions like open(), close(), get(), put(), read(), write(), seekg(), seekp(), tellg(), tellp(), eof(), fail(), bad(), good(), and clear() are described.
The document discusses file input/output in C++. It covers the header file fstream.h, stream classes like ifstream and ofstream for file input/output, opening and closing files, reading/writing characters and objects to files, detecting end of file, moving file pointers for random access, and handling errors. Functions like open(), close(), get(), put(), read(), write(), seekg(), seekp(), tellg(), tellp(), eof(), fail(), bad(), good(), and clear() are described.
The document discusses various C programming concepts like typedef, bitfields, enumeration, file I/O, text files vs binary files. typedef allows defining a new name for an already defined datatype. Bitfields allow packing structure members efficiently using bits. Enumeration defines a set of named integer constants. File I/O functions like fopen, fclose, fread, fwrite are used to read and write data to files. Text files contain human readable characters while binary files store data as bytes.
At the end of this lecture students should be able to;
Define the C standard functions for managing file input output.
Apply taught concepts for writing programs.
CS 23001 Computer Science II Data Structures & AbstractionPro.docxfaithxdunce63732
CS 23001 Computer Science II: Data Structures & Abstraction
Project #4
Spring 2015
Objectives:
· Develop and use a Tree ADT (n-ary)
· Apply and use tree traversal algorithms
· Manipulate trees by inserting and deleting nodes
· Apply and use STL
Problem:
Build a program profiler. Construct a program to instrument C++ source code to support program profiling.
It is often important to determine how many times a function or statement is executed. This is useful not only for debugging but for determining what parts of a program may need to be optimized. This process is called profiling. That is, a execution profile presents how many times each part of a program is executed using a given set of input data (or for some run time scenario). To compute a profile, statements need to be added to the code that keep track of how many times a function or statement is executed. The process of adding these statements is called instrumenting the code.
To implement a profiler one must first parse the source code and generate an Abstract Syntax Tree (AST) of the code. Each node of the AST describes the syntactic category of the code stored within it (function, statement, while-statement, etc.). So at the top level is a syntactic category corresponding to a program, class, or function (such as in the case of a main). Under that are sub-trees that further detail the syntactic categories of each part of the code. Such things as declarations, parameter lists, while-statement, and expression statements will describe the various parts of the program.
After the AST is generated it can then be traversed and the appropriate syntactic structures can be found that need to be instrumented. Once a construct is found, say a function, new code can be inserted that keeps track of how many times that function is executed.
The most difficult part of constructing a profiler is correctly parsing the source code. Unfortunately, C++ is notoriously difficult to parse. So here we will use a parsing tool called src2srcml. This tool reads in C++ code and marks up the code with XML tags (e.g., block, if, while, condition, name, etc). That is, the output is an AST in XML. The XML representation is called srcML (source code markup language).
A number of srcML data files are provided for the project. However, you can use your own program as input. To run srcML on wasp or hornet you will first need to set a PATH variable so the command can be found. You need to execute the command:
export PATH=/local/opt/srcml/bin:$PATH
It is best if you insert this line into your .bash_profile file in your home directory on wasp/hornet.
Then to generate the srcML file for your own code use the following:
src2srcml main.cpp -o main.cpp.xml
Use the following for a list of all options:
src2srcml --help
More information about srcML can be found at www.srcML.org including a list of all the tag names (see Getting Started). You can also download srcML if you want it on your own machine.
Your .
This document discusses file handling in C++. It covers key concepts like opening and closing files, reading from and writing to files, and different file access methods like sequential and random access. The document outlines the steps to handle files which include declaring a file name variable, associating it with a disk file, opening the file, using file input/output functions to read and write, and then closing the file. Common file handling functions like open(), close(), get(), put(), read(), and write() are also explained.
This document discusses file handling in C++. It explains that file handling allows storing data permanently on a computer's hard disk. The key steps for file handling are naming a file, opening it, writing data, reading data, and closing the file. It also discusses various file handling functions like fstream, ifstream, ofstream and their usage for opening, reading, writing and closing files. Functions like get(), put(), tellg(), seekg() and their usage with file streams are explained. Examples are provided to demonstrate reading from and writing to files.
This document discusses working with files in C++. It covers opening and closing files using constructors and the open() function. It describes using input and output streams to read from and write to files. It also discusses the different file stream classes like ifstream, ofstream, and fstream and their functions. Finally, it mentions the different file opening modes that can be used with the open() function.
Basics of files and its functions with exampleSunil Patel
The document discusses input/output files in C++. It covers key concepts like streams, predefined console streams, file modes, and file pointers. Binary file operations like get(), put(), read(), write(), and flush() are also summarized for reading and writing bytes from files. The main steps for file I/O in C++ are to declare a file name variable, associate it with a disk file, open the file, use the file for input/output, and close the file.
Similar to Object Oriented Programming using C++: Ch12 Streams and Files.pptx (20)
Design and optimization of ion propulsion dronebjmsejournal
Electric propulsion technology is widely used in many kinds of vehicles in recent years, and aircrafts are no exception. Technically, UAVs are electrically propelled but tend to produce a significant amount of noise and vibrations. Ion propulsion technology for drones is a potential solution to this problem. Ion propulsion technology is proven to be feasible in the earth’s atmosphere. The study presented in this article shows the design of EHD thrusters and power supply for ion propulsion drones along with performance optimization of high-voltage power supply for endurance in earth’s atmosphere.
Advanced control scheme of doubly fed induction generator for wind turbine us...IJECEIAES
This paper describes a speed control device for generating electrical energy on an electricity network based on the doubly fed induction generator (DFIG) used for wind power conversion systems. At first, a double-fed induction generator model was constructed. A control law is formulated to govern the flow of energy between the stator of a DFIG and the energy network using three types of controllers: proportional integral (PI), sliding mode controller (SMC) and second order sliding mode controller (SOSMC). Their different results in terms of power reference tracking, reaction to unexpected speed fluctuations, sensitivity to perturbations, and resilience against machine parameter alterations are compared. MATLAB/Simulink was used to conduct the simulations for the preceding study. Multiple simulations have shown very satisfying results, and the investigations demonstrate the efficacy and power-enhancing capabilities of the suggested control system.
Applications of artificial Intelligence in Mechanical Engineering.pdfAtif Razi
Historically, mechanical engineering has relied heavily on human expertise and empirical methods to solve complex problems. With the introduction of computer-aided design (CAD) and finite element analysis (FEA), the field took its first steps towards digitization. These tools allowed engineers to simulate and analyze mechanical systems with greater accuracy and efficiency. However, the sheer volume of data generated by modern engineering systems and the increasing complexity of these systems have necessitated more advanced analytical tools, paving the way for AI.
AI offers the capability to process vast amounts of data, identify patterns, and make predictions with a level of speed and accuracy unattainable by traditional methods. This has profound implications for mechanical engineering, enabling more efficient design processes, predictive maintenance strategies, and optimized manufacturing operations. AI-driven tools can learn from historical data, adapt to new information, and continuously improve their performance, making them invaluable in tackling the multifaceted challenges of modern mechanical engineering.
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...IJECEIAES
Medical image analysis has witnessed significant advancements with deep learning techniques. In the domain of brain tumor segmentation, the ability to
precisely delineate tumor boundaries from magnetic resonance imaging (MRI)
scans holds profound implications for diagnosis. This study presents an ensemble convolutional neural network (CNN) with transfer learning, integrating
the state-of-the-art Deeplabv3+ architecture with the ResNet18 backbone. The
model is rigorously trained and evaluated, exhibiting remarkable performance
metrics, including an impressive global accuracy of 99.286%, a high-class accuracy of 82.191%, a mean intersection over union (IoU) of 79.900%, a weighted
IoU of 98.620%, and a Boundary F1 (BF) score of 83.303%. Notably, a detailed comparative analysis with existing methods showcases the superiority of
our proposed model. These findings underscore the model’s competence in precise brain tumor localization, underscoring its potential to revolutionize medical
image analysis and enhance healthcare outcomes. This research paves the way
for future exploration and optimization of advanced CNN models in medical
imaging, emphasizing addressing false positives and resource efficiency.
Introduction- e - waste – definition - sources of e-waste– hazardous substances in e-waste - effects of e-waste on environment and human health- need for e-waste management– e-waste handling rules - waste minimization techniques for managing e-waste – recycling of e-waste - disposal treatment methods of e- waste – mechanism of extraction of precious metal from leaching solution-global Scenario of E-waste – E-waste in India- case studies.
Null Bangalore | Pentesters Approach to AWS IAMDivyanshu
#Abstract:
- Learn more about the real-world methods for auditing AWS IAM (Identity and Access Management) as a pentester. So let us proceed with a brief discussion of IAM as well as some typical misconfigurations and their potential exploits in order to reinforce the understanding of IAM security best practices.
- Gain actionable insights into AWS IAM policies and roles, using hands on approach.
#Prerequisites:
- Basic understanding of AWS services and architecture
- Familiarity with cloud security concepts
- Experience using the AWS Management Console or AWS CLI.
- For hands on lab create account on [killercoda.com](https://killercoda.com/cloudsecurity-scenario/)
# Scenario Covered:
- Basics of IAM in AWS
- Implementing IAM Policies with Least Privilege to Manage S3 Bucket
- Objective: Create an S3 bucket with least privilege IAM policy and validate access.
- Steps:
- Create S3 bucket.
- Attach least privilege policy to IAM user.
- Validate access.
- Exploiting IAM PassRole Misconfiguration
-Allows a user to pass a specific IAM role to an AWS service (ec2), typically used for service access delegation. Then exploit PassRole Misconfiguration granting unauthorized access to sensitive resources.
- Objective: Demonstrate how a PassRole misconfiguration can grant unauthorized access.
- Steps:
- Allow user to pass IAM role to EC2.
- Exploit misconfiguration for unauthorized access.
- Access sensitive resources.
- Exploiting IAM AssumeRole Misconfiguration with Overly Permissive Role
- An overly permissive IAM role configuration can lead to privilege escalation by creating a role with administrative privileges and allow a user to assume this role.
- Objective: Show how overly permissive IAM roles can lead to privilege escalation.
- Steps:
- Create role with administrative privileges.
- Allow user to assume the role.
- Perform administrative actions.
- Differentiation between PassRole vs AssumeRole
Try at [killercoda.com](https://killercoda.com/cloudsecurity-scenario/)
2. Stream Classes
A stream is a general name given to a flow of data.
In C++ a stream is represented by an object of a particular class. So far we’ve
used the cin and cout stream objects.
Different streams are used to represent different kinds of data flow. For
example, the ifstream class represents data flow from input disk files.
Advantages of Streams
One reason is simplicity. Another reason is that you can overload existing
operators and functions, such as the insertion (<<) and extraction (>>)
operators, to work with classes that you create.
You should know about C++ streams because they are the best way to write
data to files and to format data in memory for later use in text input/output
windows and other GUI elements.
[2]
5. The Stream Class Hierarchy
ios class is the base class for the hierarchy. It contains many constants and
member functions common to input and output operations, such as the
showpoint and fixed formatting flags
The ios class also contains a pointer to the streambuf class, which contains the
actual memory buffer into which data is read or written.
The istream and ostream classes are derived from ios and are dedicated to
input and output, respectively.
The istream class contains such functions as get(), getline(), read(), and the
overloaded extraction (>>) operators, while ostream contains put() and
write(), and the overloaded insertion (<<) operators.
The iostream class is derived from both istream and ostream by multiple
inheritance. Classes derived from it can be used with devices, such as disk
files, that may be opened for both input and output at the same time. [5]
6. The Stream Class Hierarchy
Three classes istream_withassign, ostream_withassign, and
iostream_withassign are inherited from istream, ostream, and iostream,
respectively. They add assignment operators to these classes.
The cout object, is a predefined object of the ostream_withassign class
Similarly, the cin is an object of the istream_withassign class
The classes used for input and output to the video display and keyboard are
declared in the header file IOSTREAM.
The classes used specifically for disk file I/O are declared in the file FSTREAM.
[6]
7. Disk File I/O with Streams
Most programs need to save data to disk files and read it back in. Working
with disk files requires another set of classes:
ifstream for input
fstream for both input and output
and ofstream for output.
Objects of these classes can be associated with disk files, and we can use their
member functions to read and write to the files.
These three classes are declared in the FSTREAM file.
[7]
8. Formatted File I/O
In formatted I/O, numbers are stored on disk as a series of characters. Thus
6.02, rather than being stored as a 4-byte type float or an 8-byte type double,
is stored as the characters ‘6’, ‘.’, ‘0’, and ‘2’.
This can be inefficient for numbers with many digits, but it’s appropriate in
many situations and easy to implement.
[8]
9. // writes formatted output to a file
// using << operator
#include <fstream> // for file I/O
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main()
{
char ch = 'x';
int j = 77;
double d = 6.02;
// strings without embedded spaces
string str1 = "Rashid";
string str2 = "Farid";
// create ofstream object
ofstream outfile("data.txt");
9
Example 1: Writing Data to a File
outfile << ch // insert (write) data
<< j
<< ' ' // needs space between numbers
<< d
<< str1
<< ' ' //needs spaces between strings
<< str2;
cout << "File writtenn";
system("pause");
return 0;
}
1 2
[9]
10. Example 1: Writing Data to a File
If the file doesn’t exist, it is created. If it does exist, it is truncated and the new data
replaces the old.
The outfile object acts much as cout did in previous programs, so we can use the insertion
operator (<<) to output variables of any basic type to the file.
This works because the insertion operator is appropriately overloaded in ostream, from
which ofstream is derived.
When the program terminates, the outfile object goes out of scope. This calls its destructor,
which closes the file, so we don’t need to close the file explicitly
There are several potential formatting glitches. First, you must separate numbers (such as
77 and 6.02) with nonnumeric characters.
As numbers are stored as a sequence of characters, this is the only way the extraction
operator will know, when the data is read back from the file, where one number stops and
the next one begins.
[10]
11. Example 1: Writing Data to a File
Second, strings must be separated with whitespace for the same reason. This
implies that strings cannot contain imbedded blanks.
In this example we use the space character (‘ ‘) for both kinds of delimiters.
Characters need no delimiters, since they have a fixed length.
You can verify that program has indeed written the data by examining the
DATA.TXT file with the Windows NOTEPAD accessory or the DOS command
TYPE.
[11]
12. // reads formatted output from a file
// using >> operator
#include <fstream> // for file I/O
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main() {
char ch;
int j;
double d;
string str1, str2;
// create ifstream object
ifstream infile("data.txt");
//extract (read) data from it
infile >> ch
>> j
>> d
>> str1
>> str2;
12
Example 2: Reading Data from a File
cout << ch << endl // display the data
<< j << endl
<< d << endl
<< str1 << endl
<< str2 << endl;
system("pause");
return 0;
}
1 2
[12]
13. If you’ve ever used MS-DOS, you are
probably familiar with command-line
arguments, used when invoking a
program. They are typically used to
pass the name of a data file to an
application. For example, you can
invoke a word processor application
and the document it will work on at the
same time:
C>wordproc afile.doc
Here afile.doc is a command-line
argument. How can we get a C++
program to read the command-line
arguments? Here’s an example
13
Example 3: Command-Line Arguments
#include <iostream>
using namespace std;
int main(int argc, char* argv[] ) {
// number of arguments
cout << "argc = " << argc << endl;
// display arguments
for(int j=0; j<argc; j++)
cout << "Argument " << j << " = "
<< argv[j] << endl;
return 0;
}
[13]
14. Command-Line Arguments
And here’s a sample interaction with the program:
To read command-line arguments, the main() function (don’t forget it’s a function!) must
itself be given two arguments. The first, argc (for argument count), represents the total
number of command-line arguments. The first command-line argument is always the
pathname of the current program. The remaining command-line arguments are those
typed by the user; they are delimited by the space character. In the preceding example they
are uno, dos, and tres.
[14]
15. #include <fstream> // for file
#include <iostream>
#include <process.h> //for exit()
using namespace std;
int main(int argc, char* argv[] ) {
if( argc != 2 ) {
cerr << "Format: oop filename"
<< endl;
exit(-1);
}
char ch; //character to read
ifstream infile; // to read a file
infile.open( argv[1] );// open file
15
Example 4: Command-Line Arguments
if( !infile ) { // check for errors
cerr << "nCan't open "
<< argv[1];
exit(-1);
}
while( infile.get(ch) != 0 ) //read a character
cout << ch; //display the character
return 0;
}
1 2
[15]
16. Strings with Embedded Blanks
The technique of our last examples won’t work with char* strings containing
embedded blanks.
To handle such strings, you need to write a specific delimiter character after
each string, and use the getline()function, rather than the extraction
operator, to read them in.
Our next program, outputs some strings with blanks embedded in them.
[16]
17. // file output with strings
#include <fstream> // for file I/O
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
// create file for output
ofstream outfile("data.txt");
//send text to file
outfile << "I fear thee, ancient!n";
outfile << "I fear thy skinny handn";
outfile << "And thou art long brown,n";
system("pause");
return 0;
}
17
Example 5, 6: Writing and Reading String in a File
// file input with strings
#include <fstream> // for file I/O
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
const int MAX = 80; // size of buffer
char buffer[MAX]; // character buffer
// create file for input
ifstream infile("data.txt");
while (!infile.eof()){ // until end-of-file
// read a line of text
infile.getline(buffer, MAX);
// display it
cout << buffer << endl;
}
system("pause");
return 0;
}
1 2
[17]
18. Writing and Reading String in a File
This program requires all the text lines to terminate with the ‘n’ character, and if you
encounter a file in which this is not the case, the program will hang.
The program continues to read one string at a time until it encounters an end-of-file (EOF)
condition. The EOF is a signal sent to the program from the operating system when there is
no more data to read.
However, checking specifically for an eofbit means that we won’t detect the other error
flags, such as the failbit and badbit, which may also occur, although more rarely. To do this,
we can change our loop condition:
while (infile.good()){ // until any error encountered
You can also test the stream directly. If everything is going well, the object infile returns a
nonzero value which is a pointer. Thus we can rewrite our while loop again:
while (infile){ // until any error encountered
[18]
19. // file output with characters
#include <fstream> // for file I/O
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
string str = "Time is a great teacher,"
" but unfortunately it kills all its"
" pupils. Berlioz";
// create file for output
ofstream outfile("data.txt");
for (unsigned int j = 0;
j < str.size(); j++)
// write it to file
outfile.put(str[j]);
cout << "File writtenn";
system("pause");
return 0;
}
19
Example 7, 8: Character I/O
// file input with characters
#include <fstream> // for file I/O
#include <iostream>
#include <stdlib.h>
using namespace std;
int main() {
char ch; // character to read
// create file for output
ifstream infile("data.txt");
// read until the EOF is reached
// or an error occurs
while (infile){
infile.get(ch);
// read a character
cout << ch; // display it
}
cout << endl;
system("pause");
return 0;
}
1 2
[19]
20. Binary I/O
You can write a few numbers to disk using formatted I/O, but if you’re storing
a large amount of numerical data it’s more efficient to use binary I/O, in which
numbers are stored as they are in the computer’s RAM memory, rather than
as strings of characters.
In binary I/O an int is stored in 4 bytes, whereas its text version might be
“12345”, requiring 5 bytes. Similarly, a float is always stored in 4 bytes, while
its formatted version might be “6.02314e13”, requiring 10 bytes.
example shows how an array of integers is written to disk and then read back
into memory, using binary format.
We use write(), a member of ofstream; and read(), a member of ifstream.
These functions think about data in terms of bytes (type char). They don’t care
how the data is formatted, they simply transfer a buffer full of bytes from and
to a disk file. [20]
21. // binary input and output with integers
#include <fstream> //for file streams
#include <iostream>
#include <stdlib.h>
using namespace std;
const int MAX = 100; //size of buffer
int buff[MAX]; //buffer for integers
int main() {
int i;
for (i = 0; i < MAX; i++) // fill buffer with data { 0, 1, 2, ... ,99}
buff[i] = i;
ofstream os("numbers.txt", ios::binary); // create output stream
os.write((char*)buff, MAX * sizeof(int)); // write to it
os.close(); // must close it
for (i =0; i < MAX; i++) // erase buffer
buff[i] = 0;
ifstream is("numbers.txt", ios::binary); // create input stream
is.read((char*)buff, MAX * sizeof(int)); // read from it
Example 9: Binary I/O with integers (1/2)
[21]
22. for (i = 0; i < MAX; i++) // check data
if (buff[i] != i){
cerr << i<< " Data is incorrectn";
return 1;
}
cout << "Data is correctn";
system("pause");
return 0;
}
Example 9: Binary I/O with integers (2/2)
[22]
23. Object I/O
Since C++ is an object-oriented language, it’s reasonable to wonder how
objects can be written to and read from disk.
The next examples show the process
When writing an object, we generally want to use binary mode. This writes
the same bit configuration to disk that was stored in memory, and ensures
that numerical data contained in objects is handled properly.
Here’s the listing for OPERS, which asks the user for information about an
object of class person, and then writes this object to the disk file PERSON.DAT
[23]
24. #include <fstream> // for file streams
#include <iostream>
using namespace std;
class person { // class of persons
protected:
char name[80]; // person’s name
short age; // person’s age
public:
void getData() { //get person’s data
cout << "Enter name : "; cin.get(name,80);
cout << "Enter age : " ; cin >> age;
}
};
int main() {
person pr1; // create a person
pr1.getData(); // get data for person 1
ofstream outfile("PERSON.DAT", ios::binary); // create ofstream object
outfile.write((char*) &pr1, sizeof(pr1)); // write to it
return 0;
}
Example 10: Writing Object to a File
[24]
25. // saves person object to disk
#include <fstream> // for file streams
#include <iostream>
using namespace std;
class person {
protected:
char name[80]; // person’s name
short age; // person’s age
public:
void showData() { // display person’s data
cout << "Name: " << name << endl;
cout << "Age : " << age << endl;
}
};
int main() {
person pr1; // create a person
ifstream infile("PERSON.DAT", ios::binary);
infile.read((char*) &pr1, sizeof(pr1)); // read from file
pr1.showData(); return 0;
}
Example 10: Reading Object from a File
[25]
26. istream Functions
[26]
Function Purpose
>> Formatted extraction for all basic (and overloaded) types.
get(ch) Extract one character into ch.
getline(str, MAX) Extract one line into array str, until MAX characters or the ‘n’ character
getline(str, MAX, DELIM) Extract characters into array str, until MAX characters or the DELIM character.
putback(ch) Insert last character read back into input stream.
ignore(MAX, ‘n’) Extract and discard up to MAX characters until (and including) the specified delimiter ‘n’.
ch = stream.peek( ) Read one character, leave it in stream.
read(str, MAX) For files, extract up to MAX characters into str, until EOF.
seekg(n) Set distance (n bytes) of file pointer from start of file. e.g.
infile.seekg(0, ios::end); // go to 0 bytes from end
seekg(pos, seek_dir) Set distance (in bytes) of file pointer from specified place in file. seek_dir can be ios::beg,
ios::cur, ios::end.
tellg( ) Return position (in bytes) of file pointer from start of file. e.g. int endposition = infile.tellg();
27. ostream Functions
[27]
Function Purpose
<< Formatted insertion for all basic (and overloaded) types.
put(ch) Insert one character ch into stream.
flush() Flush buffer contents and Insert newline.
write(str, SIZE) Insert SIZE characters from array str into file.
seekp(n) Set distance in n bytes of file pointer from start of file.
seekp(pos, seek_dir) Set distance (in bytes) of file pointer from specified place in file. seek_dir can be ios::beg,
ios::cur, ios::end.
tellgp( ) Return position (in bytes) of file pointer from start of file. e.g. int endposition = outfile.tellg();
28. #include <fstream> // for file streams
#include <iostream>
using namespace std;
class Book
{
protected:
char title[80];
char auther[80];
double price;
public:
void Add_Record();
void Read_All();
void Search();
void Delete();
};
Example 11: Books Management System (1/8)
[28]