Forum: C Mar 10th, 2005 |
| Replies: 13 Views: 4,260 Hello,
You're welcome. If you have any further questions regarding the information I provided, don't hesitate to ask.
- Stack Overflow |
Forum: C Mar 10th, 2005 |
| Replies: 13 Views: 4,260 Hello,
Keep in mind if the space cannot be allocated, a null pointer is returned. If you try to write to the NULL block of memory, it will cause a segmentation fault. It's best to test for NULL... |
Forum: C Mar 10th, 2005 |
| Replies: 13 Views: 4,260 Hello,
In addition, you may find this short tutorial on Segmentation Faults handy: Locating a Segmentation Fault (http://cboard.cprogramming.com/showthread.php?t=59721#post421421)
Or if you... |
Forum: C Mar 10th, 2005 |
| Replies: 13 Views: 4,260 Hello,
Indeed it should. Each call to malloc will be subsequently freed during each loop iteration.
I'm not entirely sure. I don't have any hard evidence or facts at the moment, though I have... |
Forum: C Mar 10th, 2005 |
| Replies: 13 Views: 4,260 Hello,
If I am correct in my thinking, you will have lost allocated memory in your program. Your pointer, q, is a variable. Allocating memory to it 1000 times will cause a problem.
According... |
Forum: C Mar 9th, 2005 |
| Replies: 18 Views: 6,323 Hello,
1) What I mean't by function scope is simple. All it knows is what is happening within the function, and it doesn't have a clue as to what is happening in the 'int main' part of the... |
Forum: C Mar 9th, 2005 |
| Replies: 18 Views: 6,323 Hello,
No problem. Let me answer this question by example:#include <stdio.h>
#include <stdlib.h>
void test(char **p) {
/* run test; view memory address */
printf("Function scope:... |
Forum: C Mar 9th, 2005 |
| Replies: 18 Views: 6,323 Hello,
When you call free, the memory pointed to by the passed pointer is freed, but the value of the pointer in the caller remains unchanged, because C's pass-by-value semantics mean that called... |
Forum: C Mar 9th, 2005 |
| Replies: 18 Views: 6,323 Hello,
Also, be sure to set your variable to NULL after you free the memory. Example:free(G); /* Dynamically allocated memory is freed */
G = NULL; /* This ensures that we point our pointer to... |
Forum: C Mar 9th, 2005 |
| Replies: 18 Views: 6,323 Hello,
When free() is called, a block of memory previously allocated by a call to malloc, calloc or realloc is freed:Graph G=malloc(sizeof *G); /* Memory is dynamically allocated */
if (G !=... |
Forum: Shell Scripting Mar 8th, 2005 |
| Replies: 2 Views: 34,642 Hello,
If I understand correctly, you want to replace all space occurances to "\space" where space represents the space, ' ', character:sed -i 's/ /\\ /' file
To clarify:
sed — Is the program.... |
Forum: DaniWeb Community Feedback Nov 12th, 2004 |
| Replies: 38 Views: 9,714 Were you in the red the two prior years you only had three advertisements on your site?
How much are you paying for your hosting services? Are you exceeding your bandwidth, and being charged a... |
Forum: DaniWeb Community Feedback Nov 12th, 2004 |
| Replies: 38 Views: 9,714 Ah, I'll see what I can do about the contests.
Maybe something a little simpler than my previous two contests ;)
- Stack Overflow |
Forum: C++ Nov 10th, 2004 |
| Replies: 2 Views: 2,541 Greetings,
A simple fix I saw. In your function gettemps() change:scanf("%f",temp[i]);To"scanf("%f",&temp[i]);if If you want to store the result of a scanf operation on a standard variable you... |