Wow! Thank you for the link Subsonics. This will help me a lot.
Type: Posts; User: mnd22
Wow! Thank you for the link Subsonics. This will help me a lot.
@KCfromNC
Thank you for the tip. I will check how can I use that approach. Sorry I forgot to put the success return code I just pasted a small part of the code.
Another question what are...
Still want to use C on this project just checking if there is a better way to handle this. Since there's no better solution I will just leave it like that then.
Thanks for the info.
Is there a better way to handle this situation? Everytime I open a file and allocate memory I check if it is successful. If not then free all files and memory before I return an error.
int...
:wink: lol told you its not tested but you got the idea.
You are getting double because you are passing src which now points to '\0' after "he llo" when you pass it to strcpy which will result to "he llohello".
You don't actually need an extra char buffer. You can just re use src.
void DelChar(char *src)
{
int i = 0;
while (*(src) != '\0')
{
If you are aiming for high-performance then use Unrolled Linked Lists. It stores multiple elements in a single node which greatly improves cache usage and lesser memory usage when all nodes are full...
Did you check if you are getting hits on line 118?
if((delta_energy<0)||(R<=exp(-delta_energy/Temp))) //Change spin state if delEnergy is less than 0 {
...
What happens when j = 25 and i = 1?
Your printf will be:
printf("%s", names[25][1]);
That will be out of bounds of array names. switch your for loops not i and j.
Also take note that on line 25 you are trying to change the address of the array which will not work, think about array as a constant pointer you cannot modify it. Do what laserlight suggested pass...
Yes after fread. Just before you do fwrite(). Post your updated code I am not sure how you did the changes.
You are opening the file in a+b mode. When you save the changes it will append it at the end of the file not update the data. Try to do what vart said or open the file with "r+b" then fseek at...
Here's a reference for fseek()
fseek - C++ Reference
use SEEK_SET with position 0 to put it at the beginning of the file.
regarding the printf issue. You are storing the '\n' when you hit...
You can pass an char array from the calling function. Then store the response in there so you don't need to use malloc.
So it will be like this. Just make sure that head and body will fit in...
Remember that arrays used as a function parameter are degraded to a pointer. In varfun stack is now *stack not stack[].
Here's a link that explains this further:
Question 6.21
My first thought is I don't think its actually receiving the value of 'j'. I think its only writing at this address 'AddressWriteHT1632C(0x00);' have you tried changing it and see what happens?
Since you already have the odd and even numbers separated on sort_array[]. You can use qsort() or any sort algorithm that you want and just pass the odd and even section of the array and the length...
Wow that works guys @@, thanks a lot!
iMalc you are right I am casting char to a larger int. I was hoping I can do this
FILE *fp;
fp = fopen("c:\\test.tst","wb");
if(fp) {
int pos = 500;
char buf[8];
...
Can somebody help me. I am having problems storing a signed long int ('s64') to a file. For some reason when blob.pos is > 127 when I read it from the file it will return junk value.
I think it...
Wow this is a great site laserlight! Thank you for the link!
I kept on thinking about what you said last night and I just finally realized how it works while brushing my teeth this morning ;). Thank you very much that will help me a lot.
@grumpy
I wont...
Thanks! That makes it more efficient. I did add an extra free so it will free dirPath on every code path.
@whiteflags
Can you explain further why do I need **FILE instead of *FILE? I cannot fully...
I am still pretty new to C and I learned a lot from this forum. This is a working code (In windows by the way). I already learned that you don't have to cast the return of malloc. I am wondering if...