Forum: C Aug 27th, 2009 |
| Replies: 4 Views: 769 You need to properly align your columns!
Here's an example of two else's that you missed because they were hidden by improper file alignment!
else if(check_name == CANCEL)
{... |
Forum: C Aug 11th, 2009 |
| Replies: 8 Views: 288 That looks like a homework assignment I've seen one of my kids do! |
Forum: C Aug 8th, 2009 |
| Replies: 3 Views: 313 char* modify(char *s)
{
int i,j=0;
static char temp[200];
for(i = 0; s[i]; i++)
{
if(s[i] != ' ')
{
temp[j] = s[i]; |
Forum: C Aug 4th, 2009 |
| Replies: 13 Views: 803 It's on main().
0 means successful.
else error! |
Forum: C Aug 4th, 2009 |
| Replies: 13 Views: 803 You're not showing the entire function so there is no context! |
Forum: C Aug 4th, 2009 |
| Replies: 2 Views: 354 these are only some of your problems!
You don't want 11 pointers, you want 11 tallies!
// int *arrayptr [11];
int arrayptr [11];
Shouldn't you pre-clear your tallies? |
Forum: C Jul 29th, 2009 |
| Replies: 8 Views: 216 Another way to think of this, look at the index of a book. A book about animals. So in the Index lookup bears. Bears is on page 32.
If you go to page 32 you see the topic Bears.
The index in... |
Forum: C Jul 29th, 2009 |
| Replies: 8 Views: 216 I wouldn't get bogged down with the concept of different memory.
Just think of it in simpler terms.
p is a label to apoint in memory that contains four bytes. Those four bytes are used as a... |
Forum: C Jul 29th, 2009 |
| Replies: 8 Views: 216 char name[] in essence is a label that references the memory at that location. It is not a pointer.
char *p = name;
p is a pointer, occupies memory as a pointer that contains the address of... |
Forum: C Jul 16th, 2009 |
| Replies: 18 Views: 705 You have an (i) problem.
You need to use two different variables within a nested loop, such as i and j.
for(i=0;i<2;i++)
// for(i=0;i<3;i++) {
for(x = 0; x < 3; x++ ) {
... |
Forum: C Jul 9th, 2009 |
| Replies: 11 Views: 507 Just briefly unless your assignment is to use a malloc() you don't need it here...
widthStr = (char*) malloc(5 * sizeof(char));
heightStr = (char*) malloc(5 * sizeof(char));
//Lecture des... |
Forum: C Jul 6th, 2009 |
| Replies: 7 Views: 343 Real Data? You are pointing nowhere! Whatever value was in your pointer at init time is where it will try to point! But there is no assigned memory there to store that value!
Why are you using... |
Forum: C Jul 6th, 2009 |
| Replies: 7 Views: 343 BOOM! That's a technical term!
Your pointer needs to be pointing at real data!
int *k, v;
k = &v; // k now points to the address of {v}.
*k=10; //... |
Forum: C Jul 5th, 2009 |
| Replies: 12 Views: 548 Rats! I looked right at that and skipped over it! Good catch CSurfer! |
Forum: C Jul 5th, 2009 |
| Replies: 12 Views: 548 I see several problems. You would have found them immediately if you had typedef enum's but here goes.
You enter types 1,2,3 but you submit them for processing as type artichokes, artichokes,... |
Forum: C Jul 2nd, 2009 |
| Replies: 10 Views: 463 YES!!!
Array[4] is index {0,1,2,3}
So your Array of [2][3] where as you're passing one row appears as
Array[3] so valid index is {0,1,2} index 3 is past end of array!
Change your... |
Forum: C Jul 2nd, 2009 |
| Replies: 10 Views: 463 Still out running your input array.
You're trying to pass in a row of [2][3] as input
so input[]
But you're accessing index #4. Since you now changed your osize from 10 to 4. Your output is... |
Forum: C Jul 2nd, 2009 |
| Replies: 10 Views: 463 Input array is 6 integers in size total.
Ouput is 4 integers in size. LONG ints but still ints.
long long unsigned int output[4] = {0};
long long unsigned int input[2][3] =
You pass... |
Forum: C Jul 2nd, 2009 |
| Replies: 10 Views: 463 BOOM?
Your indexing count is 10.
How big are your input and output arrays? |
Forum: C Jul 1st, 2009 |
| Replies: 4 Views: 312 char *extract(int *pos, char *array)
static char output[11] = {0};
int max = (*pos) + 10, count = 0;
// Need a terminator detection or will overrun the buffer
// on last 10... |
Forum: C Jun 28th, 2009 |
| Replies: 36 Views: 1,325 You are breaking down your number into its component parts then re-assembling the ASCII into a string.
There are many ways to write the same program.
All the $printf() functions return the... |
Forum: C Jun 28th, 2009 |
| Replies: 36 Views: 1,325 So what I posted should theoretically handle 0 to 999
nine hundred ninety-nine
0 to 9,999 isn't to hard either.
Above that you can handle with a resursion
nine hundred ninety-nine thousand nine... |
Forum: C Jun 28th, 2009 |
| Replies: 36 Views: 1,325 Here, this is untested but I've reworked your function.
You should examine how the hundred's are handled to add thousand handling!
char *string[]= {
... |
Forum: C Jun 27th, 2009 |
| Replies: 36 Views: 1,325 Does that make sense?
Post your entire code string[] and parser! |
Forum: C Jun 27th, 2009 |
| Replies: 36 Views: 1,325 if n == 0 "Zero" return;
Hundreds
h = n / 100 h:{0...9}
if (h) printf string[ h ] + string[28]
n -= h * 100
Tens left |
Forum: C Jun 27th, 2009 |
| Replies: 36 Views: 1,325 You're commiting a cardinal sin. Returning a local stack buffer from a function! Don't do that unless you're sure you a single-threaded and that buffer is declared static so it exists always.
... |
Forum: C Jun 26th, 2009 |
| Replies: 36 Views: 1,325 Missed a typo in your original. Zero was being ignored!
Also missed your || instead of &&
And only need to check for the upper range after the first test!
char *IntToarray( char *szBuf, int... |
Forum: C Jun 26th, 2009 |
| Replies: 36 Views: 1,325 So with a little cleanup...
char *IntToarray( char *szBuf, int num)
{
int j;
if(num>0 || num<=19)
strcpy( szBuf, string[num] );
else if(num>=20 || num<=100) { |
Forum: C Jun 26th, 2009 |
| Replies: 36 Views: 1,325 I've got to run but does this make sense now?
I'd recommend using one single buffer, and printing it when the entire string is built!
Also note, the cases of { 20, 100 } can be handled wither way... |
Forum: C Jun 26th, 2009 |
| Replies: 36 Views: 1,325 Using your latest post, it still has the math error.
Still using your two arrays!
char *IntToarray(int num)
{
char *pch;
int j;
char temp[100]; |
Forum: C Jun 26th, 2009 |
| Replies: 36 Views: 1,325 You have to use a scratch buffer to build a concatenated string. In your implementation you were contaminating the original source nouns by concatenating to them! |
Forum: C Jun 26th, 2009 |
| Replies: 36 Views: 1,325 I used a single string array for ease! Merely used a delta index for the extra data.
index 1's
index + 18 10's
index + 29 100's
index + 30 1000's |
Forum: C Jun 26th, 2009 |
| Replies: 36 Views: 1,325 You really need the dwarf array for optimization.
you have a math bug.
char szBuf[ 80 ];
strcpy( szBuf, string1[ num ];
else if(num>=20 || num<100) {
j=num %10;
#ifdef... |
Forum: C Jun 26th, 2009 |
| Replies: 36 Views: 1,325 char *szNoun[]= {
"zero", "one", "two", "three", "four", "five", "six", "seven",
"eight", "nine", "ten",
"eleven", "twelve", "thirteen", "fourteen", "fifteen",
"sixteen", "seventeen",... |
Forum: C Jun 26th, 2009 |
| Replies: 36 Views: 1,325 No, For a number up to 999 you have 4 tests?
If number is 0 to 20 then use it as a string table index.
if greater then that then turn it into 10's and 1's
And use them as separate indexes! |
Forum: C Jun 26th, 2009 |
| Replies: 36 Views: 1,325 Ah, 20 was on the edge, but 21 would involve hitting the list twice.
Once for "twenty" and again for "one" then glue the two halves together for "twenty-one"
30 would be "thirty" since no ones... |
Forum: C Jun 26th, 2009 |
| Replies: 36 Views: 1,325 Think Check Writing Program
ary [] = { Zero, One, ...., Nineteen Twenty, Thirty, Fourty, ... Ninety, Hundred, Thousand };
if (n <= 19)
ary[n]
else if (n < 100) // 20...99
j =... |
Forum: C Jun 25th, 2009 |
| Replies: 6 Views: 353 There's actually a simpler solution to find the smallest number divisable between 1 and N.
Do a running total with dividends!
1 2 3 4 5 6 7 8 9 10
2 x 3 x 2 x... |
Forum: C Jun 25th, 2009 |
| Replies: 6 Views: 353 Also only doing divisor by 2 is not valid because a number may be divisable by 2 but not by another even number.
How about 198 % 2 okay, then 198 % 4 ? |
Forum: C Jun 25th, 2009 |
| Replies: 6 Views: 353 Ahem, 350 is divisable by 7 with no remainder. 360 is not! |