You should try an object dump of the code
objdump -D filename>filedest
Also I tried this on my Gcc compiler which is version 4.3.2 and it behaves the same
You should try an object dump of the code
objdump -D filename>filedest
Also I tried this on my Gcc compiler which is version 4.3.2 and it behaves the same
main.o: file format elf32-i386 SYMBOL TABLE: 00000000 l df *ABS* 00000000 main.c 00000000 l d .text 00000000 .text 00000000 l d .data 00000000 .data 00000000 l d .bss 00000000 .bss 00000000 l d .rodata 00000000 .rodata 00000000 l d .note.GNU-stack 00000000 .note.GNU-stack 00000000 l d .comment 00000000 .comment 00000000 g F .text 0000006e main 00000000 *UND* 00000000 printf [b]0000006e g F .text 0000002f strlen[/b]
I notice your symbol table is for main.o so has it been linked with the libraries yet?...Or is that your point that strlen is resolved here so why is it linking to the external library in the linking stage
I would use a switch statement to filter each character you read from the file.
Then yes I agree that you can mimic getline with getchar/getc/fgetc
for example:
i have a sentence with numbers (i have 5 books), when i run my c program i want to see just (i have books) without 5.
So you want to filter what you read from the file but not change the file?
that does not use any external libraries
I must of misinterpreted this line
I didn't mean that at all. I believe that it is quite possible to do a simple 'getline' function by using getchar. It would be limited, yes, but it could be done. I don't have a copy of K&R2 at the moment, but I believe they implement (in the book) something like what I am talking about.
Edit:
There is an example of what I am talking about here.
Yes but getchar requires external libraries since it requires systems calls to interact with the stream which is maintained by the operating system....Or are we talking about a non-standard C compiler
Depends what you mean by remove..Do you mean replace with spaces or do you mean take the character out and shift everything over one space....
Maybe you could write your own function, and call it...oh, I don't know... getline? :idea:
This guy's having problems with a simple user app an you want him to interface with the system calls directly and create a function that will mimic getline?
If the solution requires threads then you have to determine what type of threads POSIX, Windows(i.e. what system is this going to run on Linux/Unix or Windows)
As for the textbook, I have no idea what it requires since I don't have it
I actually found the problem....google "getline solaris". Because I am on a Sunblade(Solaris) I cannot use getln, fgets, or basically anything other than string.h which is not supposed to be used for this program. My next way of attempting to simply solve the program will be to copy every individual character into an array using getchar and then begin copying the array into a second array that has an if statement that checks if it is a whitespace character duplicate before copying. Can anyone think of any better way to do this that does not use any external libraries or getline, getln, fgets?....basically just getchar() and putchar()
I'm confused by this???Why can't you use C standard libraries? This is a C program right? How do you intend to know for sure if the stripping is correct if you can't display or save the answer...
It says right in the attachment "use the second method in the textbook to compute the integral"
From the brief description it just looks like the summing of areas under the curve
where each area calculation is handled by its own thread...
This is my interpretation of it but I don't have the textbook
Dumb question, did you include stdio.h
just saw the extra ] and that was it... oh the joy
Thanks for the helpI also have to create a function to determine the minimum bounding rectangle of this polygon (which is just the Xmin, Ymin, Xmax, Ymax). I see how it would be easy to do if I had the X and Y coordinates in separate lists by just using xyList.sort. Is there a similar way to sort a nested list based on the first variable (x) and then for the second (y)?
I think you answered your own question, copy the x values to a list - sort and copy the y values to another list - sort and you have your max and min values
or
You could try the map function with a lambda function to achieve this
Open python's interpreter and type this. Do you get an error?
mylist = [[1,2],[3,4]]
print float(mylist[0][0])
I would check the way your accessing your list
xylist[0][1] is the way I do it
Or is your way the new Python 3.1.1 way of doing things
Your above function will work fine but not fully optimized as mine.
The reason is the extra overhead of instructions ie
for every iteration
a. Fetch the value of i from the memory and put it in a register
b. add one to it.
c. Put the result back in memory.
In my function we can avoid these few extra cycles.Yes gcc means Linux.
Cheers!!
I don't use a Windows machine but doesn't windows use a different newline combination. What I mean is Linux uses '\n\0' for new line end of string what does Windows use?
When I create my own string length function I use
int mystrlen(char *s)
{
int i = 0;
while (*s++)
++i;
return i;
}
Try this function
Also by gcc do you mean Linux?
I have no idea why this is happening but you may get better results if you gave us the name and website of the Python app
Number one your posting title is misleading "Problem with fork system call". The system call is working just the way its supposed to. I kind of see what your trying to do here, copy a file and display its progress at the same time...this to me sounds like a problem for threads
Do you mean all combinations that are words or do you mean all combinations of the letters regardless if they form a correct word?
GNU's gcc 'as' which has AT&T syntax
Oh I see
import string
global L
def second(s):
global L
L=string.split(s)
print(s)
print(L)
Then refer to it(after you import it into the main app) like
twond.L
Why don't you def your function like
def second(s):
str = string.split(s)
return str
then you can print it like
print str(second(string))
If your using old Python code with Python 3.x.x then you may have to port the programs because Python 3.x.x doesn't guarantee backwards compatibility
You mean like I said in the previous post
x=12345
print x+x[0]
This must be features on the new Python 3.1.1 because it won't work on 2.6.1
Sorry guys...this is probably really trivial but i'm new to Python.
How do you remove the first digit from a five digit number called x and then add this new number to the original x.
I need to be able to remove any of the digits and add the new number to the original one.Thanks for any help
I would change the integer to a string then strip the first character off
Yeah check out GNU's gcc or do you mean a C IDE
I am using the file ex3test.c to run the following program, but the UNIX gives the errors:
[38] $ gcc -o ex3test ex3test.c
Do you mean when you compile ex3text.c it gives you errors
You could return the address to the array of structures
I only read this quickly and I have a hard time understanding why this is only five bytes char *msg = (char *) malloc (5);
Since copy "Hello, " to it then you strcat "Fred" to it
Disregarding a return value is harmless. Well with that said I should mention that the return value is lost but if its deemed insignificant then no harm done
Whenever I've worked with linked lists they have always had a head node, internal node and a tail node. The job of the head node is to point to the first node which is the the tail node initially. The job of the tail node is to signal the end and the internal node's well they carry the data and a pointer to the next internal node or tail node.
So they would look something like
Head node->{internal node } ->{internal node }->tail node
{data structure } {data structure}
You should Google around...There is lots of linked list examples on the net
You should read the member rules
Could you show us what you have so far?
What do you have so far?
Not allowed to answer homework questions without you showing some effort...
If this is C++ code/compiler then you should be able to instruct the compiler to stop before assembling, so the output should be in the form of a assembler code file..
I really don't see the purpose of the quotes int assignment1[30]; " ";
Won't this achieve the same thing int assignment1[30];
Plus this line char totalPoints = "assignment1; + assignment2; + assignment3; + assignment4; + assignment;5 + assignment6;";
should be char totalPoints[] = "assignment1; + assignment2; + assignment3; + assignment4; + assignment;5 + assignment6;";
This above are only suggestions because I'm not really sure what your trying to accomplish here
Also, you might get more info from your print statements if you use the hex format character %x - like printf("x is %x\n", x);
If your doing a straight rev of bytes why are you stripping the first bit x = (x & 0x7FFFFFFF );
You are right, if I tried a smaller one like T[101][4001], it is ok.....
But the problem is, int T[1001][4001] is not big at all. And I need to define such arrays in my computation.
Do you know what the problem is?
Yes look at my second solution
Try defining you array like below:
#include "stdio.h"
int T[1001][4001];
int main()
{
int i=0;
int j=0;
for(j=0;j<1001;j++)
{
for(i=0;i<4001;i++)
{
T[j][i]=0;
}
}
printf("Thank you!\n");
return 0;
}
Also a seg fault is generally triggered when a user application tries to access an invalid address.
Your array maybe too big. Try decreasing the size of the array and see if the seg fault goes away...G
If I understand this you have the hard part all figured out. Just prompt for the numbers in your for loop and add them up and the divide by the total
Why don't you use the Python interpreter...It does a great job of parsing
try x ==1 or x == 2
your version is always true x ==1 or 2
since 2 is not 0 so anything or'd with a true value is true
Sorry didn't mean to come off as uppity maybe you should check some of the open source encryption libraries that are available....G4143
This is a good question. It shows you are thinking past the pages in the book. The reason so many programs can exist(by exist I mean run) at the same time is -
Modern operating system(multi tasking) will allow running programs to use the processor for a certain amount of time then save the programs environment and switch to the next program.
So if we have three programs
program a
program b
program c
then the scheduler will let "a" run for an allotted time save its environment then load "b's" environment and start executing "b" when "b's" time expires its environment is saved and "c" is loaded and "c" starts executing
Now this loop continues executing program "a" then "b" then "c" then "a" then "b"
until the programs exit or the system goes down.
Note this is a very oversimplified view of what goes on...
Also environment is the executing state of the program...i.e. register values, system values