Skip to content

Commit 9ba2eda

Browse files
Update index.html
1 parent 2f87f8b commit 9ba2eda

File tree

1 file changed

+54
-2
lines changed

1 file changed

+54
-2
lines changed

index.html

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2073,8 +2073,60 @@ <h3>Content in myfile.txt :</h3>
20732073
<div id="thursday-content-week5" class="day-content day-section">
20742074
<h2>Te Ta Thursday</h2>
20752075
<div class="content-block">
2076-
<p style="text-align: center; font-style: italic; color: #555;">CONTENT COMING SOON!</p>
2077-
</div>
2076+
<h3>Structures in C:</h3>
2077+
<p>Imagine you have a collection of data that you want to store together, like a person's details. You can create a struct to hold this data:</p>
2078+
<pre><code>struct Person {
2079+
int age;
2080+
char name[20];
2081+
};</code></pre>
2082+
</div>
2083+
<div class="content-block">
2084+
<h3>Some cool things about structures:</h3>
2085+
<ul>
2086+
<li><strong>Structure Padding:</strong> When you define a structure, the compiler might add some extra space (padding) between members to ensure they're aligned properly in memory.<br>
2087+
<p>For example:</p>
2088+
<pre><code>struct Example {
2089+
char a; // 1 byte
2090+
int b; // 4 bytes
2091+
}; // The total size might be 8 bytes due to padding</code></pre></li>
2092+
<li><strong>Bit Fields:</strong> You can specify the number of bits for a structure member, which is useful when working with limited memory:<br>
2093+
<pre><code>struct PackedData {
2094+
unsigned int flag: 1;
2095+
unsigned int mode: 2;
2096+
};</code></pre></li>
2097+
<li><strong>Nested Structures:</strong> You can define a structure within another structure:<br>
2098+
<pre><code>struct Address {
2099+
char street[20];
2100+
char city[10];
2101+
};
2102+
2103+
struct Person {
2104+
int age;
2105+
char name[20];
2106+
struct Address address;
2107+
};</code></pre></li>
2108+
</ul>
2109+
</div>
2110+
<div class="content-block">
2111+
<h3>File Handling in C:</h3>
2112+
<p>File handling allows you to read and write data to files. Here are some key functions:</p>
2113+
<ul>
2114+
<li><strong>fopen():</strong> Opens a file.</li>
2115+
<li><strong>fread()</strong> and <strong>fwrite():</strong> Read and write data to files.</li>
2116+
<li><strong>fclose():</strong> Closes a file.</li>
2117+
</ul>
2118+
</div>
2119+
<div class="content-block">
2120+
<h3>Example:</h3>
2121+
<pre><code>FILE *file = fopen("example.txt", "w");
2122+
if (file != NULL) {
2123+
fprintf(file, "Hello, world!");
2124+
fclose(file);
2125+
}</code></pre></div>
2126+
<div class="content-block">
2127+
<h3>Expected Output in example.txt :<h3>
2128+
<code>Hello, world!</code></div>
2129+
20782130
</div>
20792131
<div id="friday-content-week5" class="day-content day-section">
20802132
<h2>Function Friday</h2>

0 commit comments

Comments
 (0)