abhimanipal 91 Master Poster

*p_clsuses will resolve to **(p_clsuses+i)

In your build clauses function ... You are passing the address of a pointer as an argument .... Is there any specifc reason for passing the adress ? Can you not pass the pointer directly ....

abhimanipal 91 Master Poster

Though it would be a good idea to support a generic mount point in your C code, because the mount point could change with USB devices:

# mkdir /mnt/usbj
# mount /dev/sda1 /mnt/usbj
file = fopen("/mnt/usbj/file.txt", "a+");

Can you please explain the effect of this piece of code

abhimanipal 91 Master Poster

Can you print the Output of the merge sort ?
Also how many points are present in the input ?

abhimanipal 91 Master Poster

Can you look the C operator precendence tables for the operators *(dereference operator) and +(addition operator) ?
Then look at the while loop you have written

while (!feof(p_file) && i < (size / 8))
    {
        fgets(buffer, 8, p_file);
        
        (*p_clauses + i)->_var1[0] = buffer[0] - '0';    
        (*p_clauses + i)->_var1[1] = buffer[2] - '0';
        
        (*p_clauses + i)->_var2[0] = buffer[4] - '0';
        (*p_clauses + i)->_var2[1] = buffer[6] - '0';
        
        ++i;
    } /* End WHILE */
abhimanipal 91 Master Poster

Check out this page

abhimanipal 91 Master Poster

Conceptually sorting an array of strings is no different from sorting an array of integers.
There is one main difference. When we are comparing 2 integers, say a and b, it is quite easy to say a is greater than / lesser than / equal to b. If you are sorting arrays of strings you have to write your own compare function which can tell if the string a is greater than / equal to / less than string b

abhimanipal 91 Master Poster

Also if you declare an array like

int arr[10]

The last legal index into the array is 9. Anything beyond this and your code will crash.

abhimanipal 91 Master Poster

Read this

abhimanipal 91 Master Poster

Run this program. This should clear your confusion

#include<stdlib.h>

typedef struct Person
{
        char fname[100];
}FOO,*FOO1;



int main()
{
        FOO f1;
        FOO1 f2;
        printf("%d %d\n",sizeof(f1),sizeof(f2));

        return 0;
}
abhimanipal 91 Master Poster

Check out atof

abhimanipal 91 Master Poster

Did you try the suggestion given by @Moschops

abhimanipal 91 Master Poster

Where is the code breaking ?

Put some log statements to get a better idea of the behavior of your program

abhimanipal 91 Master Poster

Do you want to find the difference between 2 files ?

abhimanipal 91 Master Poster

There maybe an issue with file paths. The solution to this problem is

1. Write a sample program to create a file. Give the file a weird name. Say aabbccddeeffgghh.txt.
2. After you create the file, exit the program and then use the search function to locate the file. From now one keep the file SummaryStudentData.txt in that folder.

Another option is to use absolute file names as opposed to relative file names

abhimanipal 91 Master Poster

Can you give the Input which is breaking the code ? Also put some log statements to print the number of points that the dealer and the player has

abhimanipal 91 Master Poster

Maybe you want to add the total points that the student has scored.

Maybe you dont want to keep resetting the variable which is supposed to keep track of how many grades the student has got

abhimanipal 91 Master Poster

In my experience Let us C is one of the best books for the C programming language. Try finishing the book completely.

As for your question the functions you mentioned are provided in string.h ... Depending on the compiler that you are using you may or may not have it.

abhimanipal 91 Master Poster

Check out this link. It contains the operator precedence for all the operators in C

If you look at this link carefully and then look at the sequence of operations in the statement *(list)-> head you will realize your mistake

abhimanipal 91 Master Poster

In your code the declaration of the pointer account_array is fine.

char (account_array[size];

I guess you meant

char *account_array[size];
abhimanipal 91 Master Poster

Can you please explain what you are trying to achieve in the if block lines 44 - 59

abhimanipal 91 Master Poster

Can you put some log statements so that we can see the flow of control when you try to fetch a page from Daniweb ...
Paste the log output on the forum

abhimanipal 91 Master Poster

How are you compiling the program ?
There has to be a .exe file ...

abhimanipal 91 Master Poster

Did the sample code for reading files compile without any errors ?

abhimanipal 91 Master Poster

I have some observations about the pop function.... May or may not apply to you

Say you have 1,2,3,4,5 in the stack with the 5 being at the top. If I wanted to do a pop operation I would:

1. Copy the variable 5 in a temp variable. (Check for underflow)
2. Currently the stack pointer should be pointing to 5. I would store the memory address of 5 in a temporary location.
3. I would move the stack pointer to 4.
4. Delete the memory being used by the 5.
5. Return the temp variable being used to store the value 5

As always use printf / cout to narrow down your error

abhimanipal 91 Master Poster

Check out this link

abhimanipal 91 Master Poster

Try using the exact code written by AD

Form1::Form1^ form1 =gcnew Form1::Form1;
form1->textBox1->Text="Hello!";
abhimanipal 91 Master Poster

This is just a hunch but try including fstream.h instead of frstream
Also can you make a sample code to just read data from a file as most of your errors seems related to file handling options

abhimanipal 91 Master Poster

To print a file you would need to interact with device drivers of the printer ... I dont know if that is easily achievable by using standard c programing

abhimanipal 91 Master Poster

Dont & and * cancel each other out ?

int main() {

        int x = 10;
        int *p1 = &x;

        printf("p1  %p\n",p1);
        printf("*p1 %d\n",*p1);
        printf("*&p1 %p\n",*&p1);
        printf("&*p1 %p\n",&*p1);



  return 0;
};
abhimanipal 91 Master Poster

Hello Everybody,

I was recently looking some code ... The person who wrote the code was using the ping command to send some data to the google.com and then he recovered some statistics from mdev ... This link contains the source code I am referring to ...

My question is I am unable to understand the significance of mdev here ... I ran the mdev command on my Ubuntu and the command is taking forever to come back ...

Can anybody explain the significance of mdev ?

abhimanipal 91 Master Poster

I ran the code you had provided and it gave an error

$ ./test
ping: invalid option -- 'D'
Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline]
[-p pattern] [-s packetsize] [-t ttl] [-I interface or address]
[-M mtu discovery hint] [-S sndbuf]
[ -T timestamp option ] [ -Q tos ] [hop1 ...] destination
obtained the following seed: 0.0
$

abhimanipal 91 Master Poster

I ran the command as you said and I am getting an error

~$ cat /dev/random | od -tl -w4
od: invalid character `l' in type string `l'
^C
~$ ^C

abhimanipal 91 Master Poster

What is the purpose of this line ?

&*a= &(*fot);

The code fragment that you have posted does not contain any loops or recursion . Please put some cout statements to get a better idea of the region where the code is freezing

abhimanipal 91 Master Poster

Hello Everybody,

I am on a Ubuntu system and I just came across /dev/random

I tried searching for examples of how to use this utility (or file/ or command) to generate a random number but I cannot find anything.

Quick note I am trying to generate a random number on the command prompt not in a C program. Is this possible ?

abhimanipal 91 Master Poster

Also how about clearing the content in the namelist array before using the add function

for(int i=0;i<size;i++)
{
   for(int j=0;j<namelist[i].length;j++)
              namelist[i][j] = '\0';
}

Maybe overkill but wont hurt

abhimanipal 91 Master Poster

yes

abhimanipal 91 Master Poster

Don't use the ping command.
Create a socket to a remote server. Write some data to the socket.Check how much time it takes for the server to respond.
The time difference can be your seed

abhimanipal 91 Master Poster

Ok.... Dont start straight away for 30,000 words ...
Write code for the your approach for 10 words and then scale it to 30,000

abhimanipal 91 Master Poster

In the function to calculate variance is
(a) Average being calculated correctly ?
(b) Can you please use brackets to more explicitly specify the order of the arithmetic operations

When you write

variance = (double)sum_sqrs / (double)n - (average)*(average);

It will
(1) divide sum_sqrs by n
(2) multiple average by average
Subtract (2) from (1)

Is this what you want ?

abhimanipal 91 Master Poster

Can you please post the relevant code ? I cannot figure out what you are trying to say

abhimanipal 91 Master Poster

Yes ...

abhimanipal 91 Master Poster

Check out this link

abhimanipal 91 Master Poster

Vector is a C collection class . Do you really require the names of your functions to be vector and free_vector ?

abhimanipal 91 Master Poster

What is the issue with your program ?

What is the expected output and what are you getting ?

abhimanipal 91 Master Poster

An uninitialized global variable takes the value 0. Doing a 0/0 division will give you an Arithmetic exception. I think this should solve the crashing issue.

How did you compile the program ? I also got the same compilation errors that mitrmkar got

abhimanipal 91 Master Poster

One way is to check the ASCII value of each character. The space character, / character all have distinct values

abhimanipal 91 Master Poster

Check out this link

Also will your program be required to run on a non windows machine ?

abhimanipal 91 Master Poster

What is the objective of the program ?

abhimanipal 91 Master Poster

In the function to calculate the median you have used the variable i without initializing it.

abhimanipal 91 Master Poster

Quick question do you know the relevance of the keyword extern ?

I removed extern and the program compiled with just 1 warning