Thanks rag_to_riches. It all seems to work now!! I will add more string arrays and test it.
Thanks a lot!!!
Type: Posts; User: agentsmith
Thanks rag_to_riches. It all seems to work now!! I will add more string arrays and test it.
Thanks a lot!!!
Ok now I understand that bit, but how do I solve the bus error problem?? Whenever, I pass it something like "lw" or "addi", which are both not in the first array I keep getting Bus Error and I don't...
Hi. I know this is an old post but I have been unsuccessful at trying to implement the above code by dwks. At first I tried it out and it seemed only to work when I passed it a string that was...
can this chuck of if-else if statements can be converted into switch statement format? thanks
int search_opcode (char opcode[LENGTH])
{
if (( strcmp ("add", opcode) == 0) || (strcmp...
Thanks a lot, now it all works. Just shows that it's not always good idea to follow the guidelines your lecturer gives you, since obviously his code is blatantly wrong lol.
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
typedef struct List {char array[10]; struct List *next;} List;
List *insert_list (char head[10], List *tail)
{
Hi, i am trying am dealing with numbers in two's complement. If I pass a negative number to the function, it turns it into positive and works out its binary equivalent. The bit I am stuck on is...
In my code I initialize an array of 32 ints to 0. From then on, depending on the string passed to the function, appropriate array elements are changed to 1. Here is my code so far:
#include...
Thanks. Now once its in the file do I treat it as a string when retrieving it?
Is it possible for one array to contain a string and few ints?? I want to write to a text file a string followed by a few ints, so they all appear on the same line in the file. Example of what I want...
Great. I set i = 0 in check_for_label() and it all works. Thanks guys
I am writing code that searches a string for a specified character and returns its position in the array. Here's my code so far:
#include <stdio.h>
#include <string.h>
int check_for_label...
cheers, all fixed now
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
void search_array (char array[], char type)
{
if (strcmp ("nop", array) == 0){
type = 'R';
...
Ok then, suppose instead of a binary file I simply copy characters from one text file into another, whilst removing spaces between them (but blank lines still present).
My problem is that if the...
Is it possible to make fgetc skip to a new line once it encounters a certain character? Here is my code so far:
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
FILE *gfopen (char...
The aim of my code is to read in a code in a text file and discard comments, i.e. any characters after '#'. So for example, line like this:
main: addi $3,$0,40 # j = 40
is transformed...
i am writing code that basically reads in a text file and only reads in code up to a certain character. It's a simple assembler that needs to read in assembly code whilst discarding comments that...
cheers i fixed it
my code converts binary into hexadecimal. I pass an array that contains a string 0s and 1s to the function and it converts it to a string of characters that represent the hexadecimal value. The...
cool, cheers. I fixed it now. Thanks for help. However, I am a bit confused about arrays. I know that for a string you need an extra array element to hold "\0" but do I have to leave an extra element...
My code reads in a number, then produces that number in binary and converts it to string of chars. The code works correctly, however, when I run it in Mac OS X terminal my output doesn't match the...
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#define LEN 20 /* word array size */
#define HASHSIZE 12289 /* hash table size */
typedef...
yeah it is a SAX hash. thanks a lot guys
cheers. then how would i properly describe this execution in the hash function?
h ^= ( h << 5 ) + ( h >> 2 ) + p[i];
i know it has something to do with shifting but beyond that i have no clue