<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>tictactoe | Learn C Games Programming Blog</title>
	<atom:link href="https://learncgames.com/tag/tictactoe/feed/" rel="self" type="application/rss+xml" />
	<link>https://learncgames.com</link>
	<description>A blog about C, programming games and my ebook(s).</description>
	<lastBuildDate>Thu, 16 Jul 2020 13:33:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://learncgames.com/wp-content/uploads/2020/03/cropped-favicon-32x32.png</url>
	<title>tictactoe | Learn C Games Programming Blog</title>
	<link>https://learncgames.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">181446779</site>	<item>
		<title>A tictactoe (aka noughts and crosses) game in C</title>
		<link>https://learncgames.com/a-tictactoe-aka-noughts-and-crosses-game-in-c/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=a-tictactoe-aka-noughts-and-crosses-game-in-c</link>
		
		<dc:creator><![CDATA[David]]></dc:creator>
		<pubDate>Wed, 22 Jul 2020 23:00:21 +0000</pubDate>
				<category><![CDATA[C]]></category>
		<category><![CDATA[Game]]></category>
		<category><![CDATA[tictactoe]]></category>
		<guid isPermaLink="false">https://learncgames.com/?p=1028</guid>

					<description><![CDATA[<p>I was asked to write this a few month&#8217;s back and it took me 2 or 3 evenings. It&#8217;s 312 lines long in just one file. Hopefully there are enough sensible function and variable names to make sense of it. It runs in a terminal. It was compiled with Visual Studio but should not need [&#8230;]</p>
The post <a href="https://learncgames.com/a-tictactoe-aka-noughts-and-crosses-game-in-c/">A tictactoe (aka noughts and crosses) game in C</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></description>
										<content:encoded><![CDATA[<div class='__iawmlf-post-loop-links' style='display:none;' data-iawmlf-post-links='[{&quot;id&quot;:612,&quot;href&quot;:&quot;https:\/\/pixabay.com\/users\/27707-27707\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=944386&quot;,&quot;archived_href&quot;:&quot;&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[],&quot;broken&quot;:false,&quot;last_checked&quot;:null,&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:613,&quot;href&quot;:&quot;https:\/\/pixabay.com\/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=944386&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20260205102120\/https:\/\/pixabay.com\/?utm_source=link-attribution&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 16:42:06&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-13 16:32:37&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-17 08:07:30&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-02-27 19:54:57&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-05 05:25:22&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-10 10:21:31&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-03-26 13:39:46&quot;,&quot;http_code&quot;:403},{&quot;date&quot;:&quot;2026-04-06 21:45:38&quot;,&quot;http_code&quot;:403}],&quot;broken&quot;:true,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-06 21:45:38&quot;,&quot;http_code&quot;:403},&quot;process&quot;:&quot;done&quot;},{&quot;id&quot;:242,&quot;href&quot;:&quot;https:\/\/github.com\/David-H-Bolton\/C-Games&quot;,&quot;archived_href&quot;:&quot;http:\/\/web-wp.archive.org\/web\/20250321014825\/https:\/\/github.com\/David-H-Bolton\/C-Games&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-02-06 13:06:49&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-10 22:04:23&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-14 08:52:29&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-17 10:05:58&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-20 15:23:26&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-23 19:34:22&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-02-27 13:29:15&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-02 22:28:40&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-06 09:06:12&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-10 10:21:32&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-03-26 13:39:51&quot;,&quot;http_code&quot;:503},{&quot;date&quot;:&quot;2026-03-30 14:47:18&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-02 15:16:09&quot;,&quot;http_code&quot;:206},{&quot;date&quot;:&quot;2026-04-06 13:09:57&quot;,&quot;http_code&quot;:206}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-04-06 13:09:57&quot;,&quot;http_code&quot;:206},&quot;process&quot;:&quot;done&quot;}]'></div>
<figure id="attachment_1031" aria-describedby="caption-attachment-1031" style="width: 300px" class="wp-caption alignleft"><img fetchpriority="high" decoding="async" class="size-medium wp-image-1031" src="https://learncgames.com/wp-content/uploads/2020/07/game-944386_640-300x300.jpg" alt="TicTacToe aka Noughts and Crosses" width="300" height="300" srcset="https://learncgames.com/wp-content/uploads/2020/07/game-944386_640-300x300.jpg 300w, https://learncgames.com/wp-content/uploads/2020/07/game-944386_640-150x150.jpg 150w, https://learncgames.com/wp-content/uploads/2020/07/game-944386_640.jpg 640w" sizes="(max-width: 300px) 100vw, 300px" /><figcaption id="caption-attachment-1031" class="wp-caption-text">Image by <a href="https://pixabay.com/users/27707-27707/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=944386">Kevin Phillips</a> from <a href="https://pixabay.com/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=944386">Pixabay</a></figcaption></figure>
<p>I was asked to write this a few month&#8217;s back and it took me 2 or 3 evenings. It&#8217;s 312 lines long in just one file. Hopefully there are enough sensible function and variable names to make sense of it.</p>
<p>It runs in a terminal. It was compiled with Visual Studio but should not need many changes to compile with gcc/clang. (I hope!).</p>
<p>I made extensive use of pointers. For instance this function uses pointers in a for-loop.</p>
<pre><code class="language-c" data-line="">int InDanger(char piece, int * x, int * y) {

    for (*y = 0; *y &lt; 3; (*y)++) {
        if (CountRows(piece, y,0)==2) return 1;
    }

    for (*x = 0; *x &lt; 3; (*x)++) {
        if (CountCols(piece, x,0) == 2) return 2;
    }
    *x = 0;
    if (CountDiagonal(piece, x,0) == 2) return 3;
    *x = 2;
    if (CountDiagonal(piece, x,0) == 2) return 4;

    return 0; // no danger
}</code></pre>
<p>I&#8217;ve added this to the <a title="Link to C Games repository" href="https://github.com/David-H-Bolton/C-Games" target="_blank" rel="noopener noreferrer">GitHub C games repository </a>and updated the C games source page.</p>The post <a href="https://learncgames.com/a-tictactoe-aka-noughts-and-crosses-game-in-c/">A tictactoe (aka noughts and crosses) game in C</a> first appeared on <a href="https://learncgames.com">Learn C Games Programming Blog</a>.]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1028</post-id>	</item>
	</channel>
</rss>
