Ok, I figured out a way to compile it that seems to resolve the issue, thanks for the help
Type: Posts; User: williamsonj
Ok, I figured out a way to compile it that seems to resolve the issue, thanks for the help
that's what I'm trying to do but when I compile it still says it has an undefined reference
I have the functions written, and they're in the same directory
I am trying to include externally defined functions in my main function but when I try to compile using:
cc assemble.c pass1.o pass2.o getsource.o -o assemble
I get the following errors:
So should this work?
while(strstr(sourcelist[Scnt], ".") == 0)
Scnt++;
hmmmm other than the fact that it's C++ lol is there a substr function in C?
Can you tell me what's wrong with this statement?
while(strcmp(sourcelist[Scnt].substr(0, 1), ".") == 0)
Scnt++;
I'm trying to increment the Scnt counter for as long as there's a...
Wow, I just realized that the line it's trying to breakup shouldn't be getting passed at all from pass1 as it is a comment. Let me try to fix that first and then see if the out of bounds issues are...
Program received signal SIGSEGV, Segmentation fault.
0x00000034c3470db0 in strcpy () from /lib64/tls/libc.so.6
(gdb) bt
#0 0x00000034c3470db0 in strcpy () from /lib64/tls/libc.so.6
#1 ...
when allocating the memory shouldn't I be doing the following:
components.lbl = malloc(sizeof(char) * 100); /*allocate a string of 100 chars; lbl points to it */
I thought that was why I was using the following code:
char label[81], opcode[81], opr1[81], opr2[81];
int ni, xbpe;
components.lbl = label;
components.opc = opcode;
components.opr1 =...
I'll give that a shot but if I remember correctly the professor mentioned that we shouldn't have to allocate memory. Should I be allocating memory in both functions or just the calling function?
ni actually represents 2 bits in SIC/XE assembly object code. opcode + nixbpe
tabstop:
I guess what I'm trying to do is pass the address of the components in pass1 to breakup so that breakup can tokenize the sourceline and assign the correct component parts into the...
You may notice in pass1 the first instance of calling breakup I tried sending the address of components, I'm not sure if that's correct or not though.
Here is my current source as well for review/reference:
pass1.c
/* Pre-Processor Directives */
#include <string.h>
#ifndef SYMBSIZE
#define SYMBSIZE 10
Well I'm getting a segmentation fault, not really sure if I'm looking at the right place in my code. I'm supposed to be reading a test file, breaking it into an array for each line and then...
I'm still looking for any help on this if anyone has any ideas.
for (0=numraise && numraise<=9, studentname=numraise+1, numraise++)
When comparing ints you need to use == not =
You are assigning 0 to numraise here. Also, if you are comparing numraise to 0...
Just for a point of clarification on my part is
if (highscore < grade[i]) highscore = grade[i]);
the same as
if (highscore < grade[i])
highscore = grade[i]);
if (highscore < grade[i] highscore = grade[i])
I believe you want to try this instead:
if (highscore < grade[i])
highscore = grade[i];
I don't know if I posted the full functions yet or not so here we go:
pass1.c
/* Pre-Processor Directives */
#include <string.h>
#ifndef SYMBSIZE
#define SYMBSIZE 10
that assignment is in the original calling function so really I guess I should've called it components.lbl = label1; in the calling function and am trying to do strcpy(components.lbl, label2); in the...
I don't see how they could overlap in memory since components.lbl is created in the calling function and label is a local variable of the function that is called.
so label and components.lbl are the same location in memory? And if that is so then would I not need to copy the values?