user41186: I am new to Arduino and I am currently working with an Arduino Uno and SD card module - SD/MMC for database storage using the Arduino database library from https://github.com/jwhiddon/EDB.
My question is, is the char str[] type the equivalent of VARCHAR?
Here is my arbitrary record definition for my table:
struct LogEvent { 
  int logId;
  int unumber;
  char username[10];
  char fname[15]; 
  char lname[15];
  char role[6];
  char boxid[10];
  char userStatus[2];
} logEvent;


user4628: If you're referring to the SQL type VARCHAR, then, vaguely. char username[10]; for instance will define a char array of 10 bytes. A char being the equivalent of a byte. That's about it for the type. This is C++, so you're pretty close to the iron, and a char array is about as basic as it gets. No collation, no encoding (remember that a character is not always a single byte!), no indexing. Just a bunch of bytes put together.

user10794: If you mean, are these equivalent:
foo VARCHAR(100);

and:
char foo [100];

No, they are not equivalent, really. In the case of SQL you can put 100 characters into foo. In the case of C++ you would (generally speaking) put up to 99 characters into foo, with the final character being 0x00 which indicates the length of the string.
You could conceivably put 100 characters into foo but then you would have to store the size of foo in another variable.

41186: <p>I am new to Arduino and I am currently working with an Arduino Uno and SD card module - SD/MMC for database storage using the Arduino database library from <a href="https://github.com/jwhiddon/EDB" rel="nofollow noreferrer">https://github.com/jwhiddon/EDB</a>.</p>

<p>My question is, is the <code>char str[]</code> type the equivalent of <code>VARCHAR</code>?</p>

<p>Here is my arbitrary record definition for my table:</p>

<pre><code>struct LogEvent { 
  int logId;
  int unumber;
  char username[10];
  char fname[15]; 
  char lname[15];
  char role[6];
  char boxid[10];
  char userStatus[2];
} logEvent;
</code></pre>
 4628: <p>If you're referring to the SQL type <code>VARCHAR</code>, then, vaguely. <code>char username[10];</code> for instance will define a char array of 10 bytes. A <code>char</code> being the equivalent of a byte. That's about it for the type. This is C++, so you're pretty close to the iron, and a char array is about as basic as it gets. No collation, no encoding (remember that a character is not always a single byte!), no indexing. Just a bunch of bytes put together.</p>
 10794: <p>If you mean, are these equivalent:</p>

<pre><code>foo VARCHAR(100);
</code></pre>

<p>and:</p>

<pre><code>char foo [100];
</code></pre>

<p>No, they are not equivalent, really. In the case of SQL you can put 100 characters into foo. In the case of C++ you would (generally speaking) put up to 99 characters into foo, with the final character being 0x00 which indicates the length of the string.</p>

<p>You could conceivably put 100 characters into <code>foo</code> but then you would have to store the size of <code>foo</code> in another variable.</p>
