Okay If I understand then I should be doing probably this.
int main(){
freopen("err.txt","w", stderr);
FILE* input = freopen("member.d", "r", stdin);
FILE* output = freopen("log.txt",...
Type: Posts; User: roaan
Okay If I understand then I should be doing probably this.
int main(){
freopen("err.txt","w", stderr);
FILE* input = freopen("member.d", "r", stdin);
FILE* output = freopen("log.txt",...
Oops actually I made a mistake while posting the code segment. Here is the code segment that I am using.
int main(){
freopen("member.d", "r", stdin);
freopen("log.txt", "w", stdout);...
I had a program which accepted input file on the command line and redirected output to file specified in the command line. So it was essentially
$ ./name_of_program <input_file >output_file
...
A couple of things more:
1. In the code you say that your main returns an int, but you are not returning anything from it. So make sure you return an int from the main.
2. The fpurge() function...
I dont see the output as negative integer....
Extra work for me Now i have to understand this as well :) (Just kidding) Let me go through it and ill also try to come up with something unique of my own.
Thanks, now i can explain that to anyone :-).
Any insights ?
[insert]
void aligned_free(void *ptr) {
int *ptr2=(int *)ptr - 1;
ptr = (int *)ptr - *ptr2;
free(ptr);
}
Yes that makes it a lot clearer. So if instead i wish to have a alignment on a 16 bit boundary all those parameters would change accordingly. But another of the questions is that when i am trying to...
I have been tinkering around with this program but i am still unable to understand it. This is supposed to allocate memory returned my malloc and align it to a 4 byte boundary. I got this from the ...
I just came across this question and wanted to know that does the malloc only allocate memory in multiples of 2 ? So if i want to have a memory say for my case i want memory in multiples of 32 should...
I wanted to know how do i check if the two linked lists merge. What should be the algorithm for this. I can only imagine that if the two linked lists merge then they will have a Y LIKE structure with...
I was doing some bit operations and when i try to get the bit representation of a negative number say -1 on my Intel processor the value that i get is
11111111111111111111111111111111
I had...
I have written this program for the endian conversion but i am getting incorrect output. I am still unable to understand why?
[insert]
#include <stdio.h>
#include <stdlib.h>
int main(void)...
I came across this code for doing the endian conversion.
[insert]
inline void endian_swap(unsigned short& x)
{
x = (x>>8) |
(x<<8);
}
Now it works. :cool:
Yes i did that of putting a printf and i understood the fact that i cannot allocate more than 1 Mb of memory. It does not print the contents of printf after the array and it crashes before that...
I didnt get by what you mean so what stops this overflowing the space. Isnt fscanf supposed to return -1 when it reaches the end of file. And i have allocated more space than is required for my...
Here is the updated code
[insert]
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#define MAX_WORD_LENGTH 31
Okay but in this case since i have not appended any identifier to road so is it a static variable in this case.
I had a doubt about the static keyword.
[insert]
#include <stdio.h>
#include <stdlib.h>
static int count;
int road;
Still unable to make any progress. The same problem is still happening. Could it be a IDE or VS issue that the file size is very large and it is not able to allocate space for this large file size.
A couple of issues with your program are the following:
1. Never use simple main. Use int main(void) and make sure you return 0 at the end of the program.
2. With the above program there are a...
Okay i figured out the way of doing dynamic memory allocation for a 2d array using
[insert]
char **array2d;
array2d = malloc(sizeof(char *) * MAX_WORDS);
for(i = 0; i<...