may be u should look up the Arithmetic operators in C section of the book.
C - Overview of Operator Types, Arithmetic, Bitwise, Assignment, Precedence Table
when u do x % y, u get the...
Type: Posts; User: livin
may be u should look up the Arithmetic operators in C section of the book.
C - Overview of Operator Types, Arithmetic, Bitwise, Assignment, Precedence Table
when u do x % y, u get the...
Do you need to save the reversed number or print it to screen?
If it is just printing out the reverse, I would just repetedly do a number % 10 and print it out. If you need to save it, I would do...
Hmm interesting. So u cannot delete an array with delete() ? I tried delete [] student_details and it worked. I am also learning c++ after learning c. So I thought all free() translate to delete()...
Heres the piece of code I wrote to gather student details into a dynamically allocated array of structs. But when I try to delete the memory, it gives me a seg fault. I used print statements to make...
Thanks a lot..that helped.
Hi,
I am trying to work on my first cpp assignment which requires me to break the code into multiple files. I also have to work with structures. I am a little confused as to where my struct...
Yes the above reply is correct. On a more general level, u need to either define the function before you use it or declare it before using it in main and define it after main.
Hi ,
here is the code I am trying to get running on my linux system. I emulated NUMA on my laptop using the numa=fake=2 boot time option. The source code is from the documentation I found...
What it means is that u cannot rearrange the characters of a string when u declare it as a constant like char *str = "some_string". U can however rearrange the characters when u save the string as an...
Yes u are right. I think it was an overseen error as a result of an unchecked keystroke in vim. But the actual code had a pointer declared.
Thank you oogabooga. I think that will work. I thought all...
Hi,
I need help with this program . I am doing something wrong with pointer addition.
/* program allocates 16 MB of memory on heap and writes to every 2MB interval*/
#include...
yeah I saw that..but I couldn't find anything abt how to use it right. Could you see some obvious solutions I can try?
Hi,
I wrote this small piece of code to test the effect of O_DIRECT flag. But for some strange reason the program fails at the write function line with invalid argument. I cant seem to...
iMalc, I dont think allocating bytes+1 is the right size. Each page is represented using the last bit of a byte. So I would just be needing as mnay bytes as the pages available. That is why i...
k thanks I did that. but removing the (void *) is warning me that I am comparing a pointer to an interger. I think (void *) is necessary too. But the actual problem comes when I am freeing the...
Hi guys. Sorry for the late response. The code was in my laptop and I had to wait till I go home to fetch it. Its part of a bigger shared project. What I am trying to do here is trying to get a...
Hi,
I need help with this snippet of code which breaks down at the free() line.
/* called function */
unsigned char* func(){
unsigned long length = 9;
unsigned char *p = NULL;
Thank you all. I was almost convinced I had some basic concepts missing. Now it makes sense.
hi,
I came across this code online on a tutorial site. This part of the code confused me.
/*
* parse--split the command in buf into
* individual arguments.
*/...
Hi,
I wrote this simple file copy program to copy contents from input to output file. The program kind of rins into an infinite loop at read/write stage. Can anyone please point out where I am...
oh ok. I included the unistd.h and it worked. thanks you two!
Hi,
I wrote a simple piece of code as an exercise in file_descriptors which opens a file and then closes it using open and close. When I try to compile it using the flags -Wall -ansi...
Wonderful explanation..thanks a lot.
Ok I think I got what u mean when u said u can do arithmetic on pointers. But in the line
I know ptr points to the second element of p which is itself a pointer to an array of integers, arr....
I have a slight confusion on the output of first printf
when we say *prt-arr, *ptr is a pointer to int and hence holds an address. when we do *ptr - arr, we are subtracting an array arr form...