<?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>Linux Ask! &#187; C</title>
	<atom:link href="http://www.linuxask.com/topics/programming/c/feed" rel="self" type="application/rss+xml" />
	<link>http://www.linuxask.com</link>
	<description>Linux Ask! is a Q &#38; A web site specific for Linux related questions such as how to use common Linux commands.</description>
	<lastBuildDate>Tue, 05 May 2015 07:15:40 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.9.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
	<item>
		<title>Connect MySQL server using C</title>
		<link>http://www.linuxask.com/questions/connect-mysql-server-using-c</link>
		<comments>http://www.linuxask.com/questions/connect-mysql-server-using-c#comments</comments>
		<pubDate>Sun, 26 Sep 2010 17:11:41 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[C]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=2147</guid>
		<description><![CDATA[Connect MySQL server using C Answer: Below show a code sample for how to connect to MySQL server using C programming language. #include &#60;stdio.h&#62; #include &#60;stdlib.h&#62; #include "mysql.h" MYSQL mysql; MYSQL_RES *res; MYSQL_ROW row; void exiterr(int exitcode) { fprintf( stderr, "%s\n", mysql_error(&#038;mysql) ); exit( exitcode ); } int main() { uint i = 0; if <a href='http://www.linuxask.com/questions/connect-mysql-server-using-c' class='excerpt-more'>[...]</a><div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/cant-connect-to-local-mysql-server-through-socket" rel="bookmark" title="Can&#8217;t connect to local MySQL server through socket">Can&#8217;t connect to local MySQL server through socket </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-connect-mysql-without-using-password" rel="bookmark" title="How to connect MySQL without using password">How to connect MySQL without using password </a></li>
<li><a href="http://www.linuxask.com/questions/disable-mysql-server-from-listening-for-tcpip-connections" rel="bookmark" title="Disable MySQL server from listening for TCP/IP connections">Disable MySQL server from listening for TCP/IP connections </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Connect MySQL server using C</p>
<p><strong>Answer:</strong></p>
<p>Below show a code sample for how to connect to <strong>MySQL </strong>server using C programming language.</p>
<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include "mysql.h"

MYSQL mysql;
MYSQL_RES *res;
MYSQL_ROW row;

void exiterr(int exitcode)
{
	fprintf( stderr, "%s\n", mysql_error(&#038;mysql) );
	exit( exitcode );
}

int main()
{
	uint i = 0;

	if (!(mysql_connect(&#038;mysql,"host","username","password"))) 
		exiterr(1);

	if (mysql_select_db(&#038;mysql,"payroll"))
		exiterr(2);

	if (mysql_query(&#038;mysql,"SELECT name,rate FROM emp_master"))
		exiterr(3);

	if (!(res = mysql_store_result(&#038;mysql)))
		exiterr(4);

	while((row = mysql_fetch_row(res))) {
		for (i=0 ; i < mysql_num_fields(res); i++) 
			printf("%s\n",row[i]);
	}

	mysql_free_result(res);
	mysql_close(&#038;mysql);
}
</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/cant-connect-to-local-mysql-server-through-socket" rel="bookmark" title="Can&#8217;t connect to local MySQL server through socket">Can&#8217;t connect to local MySQL server through socket </a></li>
<li><a href="http://www.linuxask.com/questions/how-to-connect-mysql-without-using-password" rel="bookmark" title="How to connect MySQL without using password">How to connect MySQL without using password </a></li>
<li><a href="http://www.linuxask.com/questions/disable-mysql-server-from-listening-for-tcpip-connections" rel="bookmark" title="Disable MySQL server from listening for TCP/IP connections">Disable MySQL server from listening for TCP/IP connections </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/connect-mysql-server-using-c/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code formatting and indentation in Vim</title>
		<link>http://www.linuxask.com/questions/code-formatting-and-indentation-in-vim</link>
		<comments>http://www.linuxask.com/questions/code-formatting-and-indentation-in-vim#comments</comments>
		<pubDate>Sun, 19 Sep 2010 15:50:30 +0000</pubDate>
		<dc:creator><![CDATA[Linux Ask!]]></dc:creator>
				<category><![CDATA[Accessories]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[vi]]></category>

		<guid isPermaLink="false">http://www.linuxask.com/?p=2256</guid>
		<description><![CDATA[Code formatting and indentation in VIM Answer: Vim support code formatting and auto indentation - if you tell Vim to know the filetype (either by file extension, or by setting the filetype) e.g. A simple C program (test.c) #include main() { for(int i=0;i<div class='yarpp-related-rss'>

Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-set-the-filetype-in-vim" rel="bookmark" title="How to set the filetype in Vim">How to set the filetype in Vim </a></li>
<li><a href="http://www.linuxask.com/questions/connect-mysql-server-using-c" rel="bookmark" title="Connect MySQL server using C">Connect MySQL server using C </a></li>
<li><a href="http://www.linuxask.com/questions/how-do-i-find-the-current-module-name-in-python" rel="bookmark" title="How do I find the current module name in Python?">How do I find the current module name in Python? </a></li>
</ol>
</div>
]]></description>
				<content:encoded><![CDATA[<p>Code formatting and indentation in VIM</p>
<p><strong>Answer:</strong></p>
<p><strong>Vim </strong>support code formatting and auto indentation - if you tell Vim to know the filetype (either by file extension, or by <a href="http://www.linuxask.com/questions/how-to-set-the-filetype-in-vim">setting the filetype</a>)</p>
<p>e.g. A simple C program (<strong>test.c</strong>)</p>
<pre><code>
#include <stdio.h>

main()
{
for(int i=0;i<10;i++)
{ 
printf ("Hello World!\n");
}
}
</code></pre>
<p>Then type following in Vim command mode (by pressing <strong>Esc</strong>):</p>
<p><code>gg=G</code></p>
<p>Now the code will be formatted to:</p>
<pre><code>#include <stdio.h>

main()
{
    for(int i=0;i<10;i++)
    {
        printf ("Hello World!\n");
    }
}
</code></pre>
<div class='yarpp-related-rss'>
<p>Related posts:<ol>
<li><a href="http://www.linuxask.com/questions/how-to-set-the-filetype-in-vim" rel="bookmark" title="How to set the filetype in Vim">How to set the filetype in Vim </a></li>
<li><a href="http://www.linuxask.com/questions/connect-mysql-server-using-c" rel="bookmark" title="Connect MySQL server using C">Connect MySQL server using C </a></li>
<li><a href="http://www.linuxask.com/questions/how-do-i-find-the-current-module-name-in-python" rel="bookmark" title="How do I find the current module name in Python?">How do I find the current module name in Python? </a></li>
</ol></p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.linuxask.com/questions/code-formatting-and-indentation-in-vim/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
