Forum: C Oct 27th, 2009 |
| Replies: 1 Views: 173 Code, what code?
If I understand your need you need edge triggering. Assuming high until pull down upon edge trigger.
Here's some C code. You need to create an assembly language equivalent!
... |
Forum: C Sep 12th, 2009 |
| Replies: 2 Views: 203 You aren't being very clear due to grammatical errors in your posting!
ASSUMING You want the employee closest to the average
First sum and count the number of employees.
If 0 then none
If 1... |
Forum: C Sep 10th, 2009 |
| Replies: 2 Views: 869 I am assuming you are reading an ASCII file. Do not overwrite the last byte in the file. Get file length. Allocated buffer of size+1. Read file of size into the buffer. Set terminator (that... |
Forum: C Aug 27th, 2009 |
| Replies: 4 Views: 739 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 12th, 2009 |
| Replies: 1 Views: 707 count = 0
Loop for each character
if character not a <CR>
count += (int)str[ index ] |
Forum: C Aug 11th, 2009 |
| Replies: 8 Views: 287 They started with garbage.
The flip side is that items are pushed right to left.
The second argument did a post increment meaning the <i> was pushed first then incremented.
The first argument... |
Forum: C Aug 11th, 2009 |
| Replies: 8 Views: 287 That looks like a homework assignment I've seen one of my kids do! |
Forum: C Aug 10th, 2009 |
| Replies: 1 Views: 231 FILE *sp;
//STR* sp;
sp = fopen("SAMPLE.DAT", "rb");
don't forget when you return from fun()
if (NULL != sp)
{ |
Forum: C Aug 9th, 2009 |
| Replies: 10 Views: 675 The allocations really should be...
matrix = (int **)malloc(size * sizeof(int*));
//Perform check
for (i = 0; i < size; i++)
{
matrix[i] = (int... |
Forum: C Aug 8th, 2009 |
| Replies: 10 Views: 675 You really need to post the entire code for us to understand your problem. Pointer declaration, allocation looked okay, access thus usage! |
Forum: C Aug 8th, 2009 |
| Replies: 3 Views: 309 Binary size is still the same. I only removed the empty comparison, and the more verbose declaration!
You could use a strtok function to make it smaller if that's allowed!
char *p = strtok( s,... |
Forum: C Aug 8th, 2009 |
| Replies: 2 Views: 271 Okay, write is kind of okay. But your read isn't.
Either pass in an ASCII buffer into the function or make the buffer static. Passing in the buffer is the better solution!
You may want to use... |
Forum: C Aug 8th, 2009 |
| Replies: 1 Views: 266 One to see how arguments are passed into an application.
myapp 8 4
They want you to write your missing functions.
So prototype them and pass a 0 response just to rough them in and get a clean... |
Forum: C Aug 8th, 2009 |
| Replies: 10 Views: 675 You could create an access function and allocate an array[ size * size * SIZEOF(int) ];
And use a row,column access function.
OR
Use calloc( sizeof(int) * SIZE, sizeof(int) * SIZE ) |
Forum: C Aug 8th, 2009 |
| Replies: 3 Views: 309 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 8th, 2009 |
| Replies: 2 Views: 350 I'm not exactly sure what you're trying to do but you can create your own data type.
typedef unsigned char byte;
byte b; |
Forum: C Aug 7th, 2009 |
| Replies: 12 Views: 534 never mind I really goofed up. After each strtok you'll need to do a strlen and then reverse that chunk! Not the pointer math I was trying to do! |
Forum: C Aug 6th, 2009 |
| Replies: 6 Views: 264 Mouse runs 8km/hr.
Assuming mouse is frightened.
Snake = s, mouse = m
dy = mY-sY dx=mX-sX
So dy/dx is Direction opposite from snake.
Mouse runs 8km/hr = 8000m/hr = 133.33m/min =... |
Forum: C Aug 6th, 2009 |
| Replies: 12 Views: 534 While driving into work I realized I had a bug.
// strrev( q+j, i )
strrev( q+j, i-j ) |
Forum: C Aug 6th, 2009 |
| Replies: 12 Views: 534 Hmm! a problem!
"i had a bike"
"ekib a dah i" <-- First the full string reverse
"bikea dah i" <-- First reversal !RATS!
Let's do some code corrections!
n = strlen(str) |
Forum: C Aug 6th, 2009 |
| Replies: 12 Views: 534 So use strtok() as the parser, but doesn't the method I pointed out still work?
n = strlen(str)
strrev( str, n )
q = str
p = strtok( str, " " ) # Get 'new' 1st word
while( p )
n =... |
Forum: C Aug 6th, 2009 |
| Replies: 12 Views: 534 Write a string reverse function to reverse a string from one pointer of N bytes.
First reverse the entire string.
Then parse the string looking for 1st last character of each word, then reverse... |
Forum: C Aug 4th, 2009 |
| Replies: 13 Views: 770 It's on main().
0 means successful.
else error! |
Forum: C Aug 4th, 2009 |
| Replies: 13 Views: 770 You're not showing the entire function so there is no context! |
Forum: C Aug 4th, 2009 |
| Replies: 6 Views: 264 Simple word problem. Just like math change your word problem into a mathematical expression.
Each animal has its own X,Y on a graph, so you'll need to enter each coordinate by keyboard.
You... |
Forum: C Aug 4th, 2009 |
| Replies: 2 Views: 350 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 Aug 1st, 2009 |
| Replies: 3 Views: 371 You mention project. Is this a C class final project?
Watch your [x][y] indexing. You called your roughed in getcoord(x,y) but in getcoord you did a [j][i]. There's nothing wrong with that but it... |
Forum: C Jul 29th, 2009 |
| Replies: 8 Views: 214 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: 214 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: 214 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 29th, 2009 |
| Replies: 1 Views: 750 And how long did you spend on this?
Draw it on paper! Use multiple colors to work out insertions and removals.
Your amount of code is inadequate. Maybe spend more time listening in the... |
Forum: C Jul 25th, 2009 |
| Replies: 5 Views: 236 As I posted { 1, 0 }
From what I remember as the early days of C (spec may have changed since) there was NO specification as to order of the pushes, or how data was processed vs time of push. I... |
Forum: C Jul 25th, 2009 |
| Replies: 5 Views: 236 What compiler are you using? Normally that is correct
The contents of i is pushed
0
Then the output of the scan, 1 character scanned
1
So printout 1 0
If you're seeing the character... |
Forum: C Jul 24th, 2009 |
| Replies: 3 Views: 404 Shouldn't you buy the Code Composer Studio IDE from Texas Instruments for their MSP430 processor? (Or atleast download their evaluation version available on their website?)
Or look into the GCC... |
Forum: C Jul 22nd, 2009 |
| Replies: 3 Views: 293 Easy. You have a typicall Server-client situation.
I normally work with Windows not Linux but you have a server that runs a Watchdog application. It establishes the verification, tracks number of... |
Forum: C Jul 22nd, 2009 |
| Replies: 5 Views: 432 Many ways.
Review your trignometry, Sine, Cosine to be exact.
There are ways to do it without trig, but trig is the simplest!
You can also do it with two bitmaps. One contains an image.
The... |
Forum: C Jul 22nd, 2009 |
| Replies: 8 Views: 669 It would be inappropriate to write the code in C or assembly for you.
Waiting in a while loop for input on an embedded application is not a good thing to do.
I practically gave you the code in... |
Forum: C Jul 21st, 2009 |
| Replies: 8 Views: 669 Your key delay is too short 50/1000 = 20/second
Should be around 200. Use a 5
You need edge triggering.
swLast = getbits
loop:
sw = getbits
swEdge = sw ^ swLast |
Forum: C Jul 21st, 2009 |
| Replies: 8 Views: 669 Okay so now I'm confused. You have two independent switches left and right. Built in pull-ups so when you close the switch you shunt the pin to ground, thus causing a low input.
It appears to work... |
Forum: C Jul 21st, 2009 |
| Replies: 8 Views: 669 Are you sure your inputs are on port T pins PT#0 and PT#1 ?
What exact processor are you using? |