jephthah 1,888 Posting Maven

use fgets to read the source file one line at a time. this will take a small character array of some arbitrary length. say 80 or 120 characters. you could do it a lot smaller, but i don't see any reason why you would want to..

use fprintf to write those single lines, one line at a time, to your destination file.

these two functions are contained in a while loop that continues to execute as long as there are lines left to read in the source file.

while (fgets(buffer, 80, fileHandle1) != NULL)
    fprintf(filehandle2, "%s", buffer);

note, see where i hardcoded '80' as the size of the read. this is not a good practice, and would be better served using a #define'd constant, say MAX_BUFFER_READ, and the character buffer itself will need to be one character larger than this, to account for the terminating NULL character.

#define MAX_BUFFER_READ   80

char buffer[MAX_BUFFER_READ + 1];

while (fgets(buffer, MAX_BUFFER_READ, fileHandle1) != NULL)
    fprintf(filehandle2, "%s", buffer);

.

jephthah 1,888 Posting Maven

yes, use fgets. it gets the whole line up to the newline character or the maximum number of characters argument. fscanf, as you have it written, will get up to the first whitespace. if there's any chance of whitespace variance of your files, you will have to do more complex programming with fscanf.

jephthah 1,888 Posting Maven

yes, C is full chock full of time functions. just check out the standard <time.h> library

jephthah 1,888 Posting Maven

The only way that I am able to do well in programming is because I am sort of a hard worker. ... I like routines and do menial tasks very well

sounds like a career in databases is for you.

I am really not that smart.

then it will be best if you get on a management track as soon as possible.

jephthah 1,888 Posting Maven

Here is a good example of why threads should NOT be closed

there's nothing redeeming about that thread. at this point, the only thing that can be added are warnings and disclaimers.

if we think such an effort is a good exercise with instructive value, then there's a lot of horrible code snippets out there that still need to be decisively shot and buried.


.

jephthah 1,888 Posting Maven

as an aside, check out TeraTerm. its probably the best Serial/FTP/SSH terminal interface available. if you're going to do any amount of serial work, you really need to get away from HyperTerm.

http://www.ayera.com/teraterm/

jephthah 1,888 Posting Maven

never mind, i just saw the above post.

.

jephthah 1,888 Posting Maven

dont use float

do use double

if you want to round up to the next single unit (one's place), then just add 1.0 and recast it as an int to drop the fractional parts.

if you want to round up at a certain decimal place, then first multiply by a power of 10 to the number of decimal places you want to round (e.g., 4 decimal places = 10^4 = 10000), then add 1.0 and recast as an int to drop the fractional parts, then divide by that same power of 10.

example, to round a number to the highest 1/100'ths place:

double x = 123.1234;

printf("original value is %f\n",x);

               // x =   123.1234
x = x * 100;   // x = 12312.3400
x = (int)x + 1 // x = 12313.0000
x = x / 100    // x =   123.1300

printf("rounded value is  %f\n",x);

.

jephthah 1,888 Posting Maven

use fgets to read from the first file
use fprintf or fputs to write to the second file.

here's the most basic example. error checking and user input not included.

readhandle = fopen(readfilename,"r")
writehandle = fopen(writefilename,"w")

while ( fgets(readbuffer, MAX_LINE_LENGTH, readhandle) != NULL )
   fprintf(writehandle, "%d %s", strlen(readbuffer), readbuffer);

fclose(readhandle);
fclose(writehandle);
jephthah 1,888 Posting Maven

i've been nothing but polite :)

calling a 20-year-old obsolete compiler with deprecated libraries a piece of junk is just telling it like it is. anyone who teaches with such junk in the 21st Century is either guilty of professional negligence or just plain incompetent.

the truth is not constrained by niceties of politeness.

jephthah 1,888 Posting Maven

sure, here you go.... this should do it:

for(;;)
{
    read post #11;
}
jephthah 1,888 Posting Maven

go to this page http://www.codecutter.net/tools/winbgim/

get the download. the zip file contains 3 items.

the files winbgim.h and graphics.h must be copied to your MinGW include directory.
the folder libbgi.a must be copied to your MingW lib directory.

include the appropriate header files to use the functions in your program.

jephthah 1,888 Posting Maven

hmm... yeah, i guess that was a rather bold assertion.

maybe some of the more provincial backwater ones do the same thing as NIIT.

jephthah 1,888 Posting Maven

i second that.

jephthah 1,888 Posting Maven

oh, oops. sorry for the neg rep to Robert and FBody.

I'll find a post to give you green on tomorrow. maybe someone else will make your posts, above, green too.

my bad.

jephthah 1,888 Posting Maven

interesting read. thanks, Martin, and welcome. Pop on by the C Forums when you feel like it. we have a special tag "gimmetehcodez" for those homework-seeking posts you enjoy.

jephthah 1,888 Posting Maven

malloc memory is typically called the "heap". We can just say that the "heap" is in your RAM. Not a stupid question: some people will argue for days about what exactly constitutes the heap, but I'm not one of them (i argue for days about other things)

So the 6GB memory we're talking about, the RAM, is contained on cards inserted into slots on the motherboard. it is *not* the hard drive.

If you are working on your own PC with Windows OS, you can find the amount of RAM by going into MyComputer and right-click Properties.

But if you don't already know how much RAM you have, then you don't have 6GB of RAM. Because that's a lot. not a ridiculous amount, but enough that you'd know what you were buying when you paid extra for a high-end computer with extra memory

and this 6GB, this is above and beyond what is required to run your OS and normal background processes. if you have Windows Vista, for instance, you would need 2GB more on top of that, for a total of 8GB.

so yes, the answer as someone else mentioned, is that you need to come up with a more memory-efficient algorithm.

jephthah 1,888 Posting Maven

Tell me one thing. If I have a floating point number like 123.456
and then if I multiply it by say 1000 then will it become 123456.000 or it might have the possibility of becoming like 123455.999 or something like that as a result of the multiplication.

that's why you add 0.5 to the float before you (1) cast the value as an integer (removing the fractional parts) then (2) divide it by 1000, keeping the result as a float (double)

the end result is that you have the precision you want with none of the extra fractional part beyond that.

and yeah, read narue's link. it's a good one.

jephthah 1,888 Posting Maven

hmm. norton sucks, too.

but there was a "Hello World" virus a while back, IIRC.

jephthah 1,888 Posting Maven

epsilon definitely depends on the application. i prefer to just hold it out at arm's length and close one eye. if it lines up, we're good. that's called "engineering approximation". but, sadly, the quality engineers don't like it. :(

for large integers like factorials use a big number library, not floating point.

for money, you have to be aware of and careful of rounding errors. i've never heard of using strings, but i guess you could. i dont' program things involving money, so i don't know. personally when i need to account for rounding, i just round and truncate all the remaining digits after each operation as necessary.

to round to *nearest* whole cent:

(double)dollars = dollars * 100
(double)dollars = dollars + 0.5
(double)dollars = (cast as integer)dollars / 100.0

.

jephthah 1,888 Posting Maven

no worries. you weren't misleading anyone. this is a common event with new users. i'll just tell you now, and then you'll know

if you stick around you can get a lot of help. just read the sticky posts at the top of the main C Forum page on what the community here expects.

basically it's three simple things:

-- post your code when you want specific help.
-- use [code] tags so we can read your code.
-- don't hijack other people's threads.

stick with that and you'll get along swimmingly :)

jephthah 1,888 Posting Maven

One other potential problem: If you're certain you have the physical memory, check to see if you forgot to

#include <stdlib.h>

?

if so, then the malloc doesnt have a prototype and thinks that it's returning a pointer to INT.

also you should not cast the return of malloc. malloc returns a void pointer and so the cast is redundant. to cast the return is bad practice and doing so can mask the cause of these sorts of malloc problems.


.

jephthah 1,888 Posting Maven

maybe i'm missing some details, but it seems to me that you're trying to allocate > 5GB of ram, above and beyond whatever your operating system and its various running processes require. it looks like you dont have the RAM, so your computer faults.

jephthah 1,888 Posting Maven

you need general help? okay, start here: http://www.gnupg.org/documentation/manuals/gcrypt/

and get expert support here: http://www.gnupg.org/documentation/mailing-lists.en.html ... i recommend gnupg-users@gnupg.org rather than the gcrypt devel list, unless you feel like getting a scolding.


we're not against trying to help, but you've got to give us some more to go on than just "can you hook a brotha up?"

also, this is a general C forum; we mostly stick to standard C. what you're asking about is a specialized library. some people here may be familiar with it, but many are not.

if you have specific problem and post your code along with an explanation of whats' going wrong, then maybe I or someone else can help you.


.

jephthah 1,888 Posting Maven

i believe Dev C++ keeps the command window open after execution. thus the command prompt to "hit any key to continue" which wouldnt be visible if the window had disappeared.

the problem, Prade, is somewhere in your code. either youre not outputting it correctly, or some logic is working different than you intended so the output is skipped altogether.

unfortunately, i'm not a mindreader and i'm not a good guesser.

jephthah 1,888 Posting Maven

i'm sure the PHP forum will be your best source for help. good luck.

jephthah 1,888 Posting Maven

if it were me, i'd probably get on the CVS help mailing list and ask the experts if there's a way to restore.

for the best chance of getting help from them, you'll want to clearly and concisely describe what exactly you had, what you did, and what you have now.

jephthah 1,888 Posting Maven
Salem commented: An appropriately cryptic, yet useful response. +20
jephthah 1,888 Posting Maven

welcome to daniweb. please familiarize yourself with the forum rules. you attract the ire of regulars when you bump old threads long dead with new questions, or otherwise "hijack" someone else's thread. Notice your question has been moved to it's own thread.

as to your problem .... pthreads.h and sched.h libraries are a common way to handle this: http://cs.pub.ro/~apc/2003/resources/pthreads/uguide/users-12.htm

the windows API has different method: http://www.codeproject.com/KB/threads/crtmultithreading.aspx

jephthah 1,888 Posting Maven

using the libcurl library is independent of whether or not you use the MinGW compiler. it's a library, you compile it to be used on your system. the library is then invoked to build an executable that can be distributed to any machine running a similar OS.

you should focus on getting libcurl working. i believe there was a recent thread about how to use the libcurl library to do what you're asking.

jephthah 1,888 Posting Maven

um, yeah... I'd love to visit India, but it's not going to be to visit your version of our community colleges.

We've got thousands of them. some are better than others, but i guarantee you none of them teach on 20-year-old obsolete compilers.

jephthah 1,888 Posting Maven

quickheal is a virtually-unknown AV product. the few reviews i find, complain that it prone to registering false positives. some reviewers have found it makes their computer virtually unusable.

I recommend you remove your crappy AV software and get something with a decent reputation. many people use AVG. I personally don't use any anything.

jephthah 1,888 Posting Maven

no, this thread is appropriate.

we have constant problems with many students in the C and C++ forums being taught in an incompetent manner on deprecated systems using obsolete coding practices, and apparently they are largely coming from NIIT.

personally, i'd like to hear a representative from NIIT come on here and defend the policy of using 20-year-old non-standard compilers, deprecated libraries that are incompatable with the rest of western civilization.

its not like there arent other options available. its not like they're even saving money. full-featured C and C++ development environments are available with standard-compliant compilers. and they're completely free.

it's not like this is some obscure language. this is C and C++, probably teh most popular and widely programmed language, used in multiple arenas. if NIIT will hobble their students with crap compilers like Turbo C++, there's no telling what other kind of garbage they're passing off


.

The ICE Man commented: L0L, well said :) +0
jephthah 1,888 Posting Maven

yeah, that's most people's reaction. even my wife.

jephthah 1,888 Posting Maven

everybody loves to hate on Schildt, don't they?

i think the majority of criticisms against his C: A Reference Manual, are trivial. I'm not saying it's a great book, and there are undoubtedly some errors, but it's not as bad as the bandwagon lined up against him would like to make it.

There are very few books out there subject to such scrutiny, that are free of errors. this whole "bullschildt" business is the result of two people on the standards committee apparently having personal grievances against him and setting out on a smear campaign.

there are very few people on these boards who could compete with schildt. Only one person for certain, but I won't name her name.

jephthah 1,888 Posting Maven

Only older kernels that haven't been updated would have MD5, now ... you should check with the homepage of the version of Linux you are interested in. I don't know of any list of the distro's, and what encryption each one is using.

it doesnt depend on the kernel, and the homepage isnt going to tell you what hash is used for password authentication.

if you're going to "me too" a thread, at least post some useful or at least correct information.

the password hashing algorithm is set in the /etc/pam.d by the pam_unix login script. any hash method can be set, whehter it's Blowfish or SHA256 or SHA512 or others. MD5 is still an option but probably should not be set. there are provisions to revert to a default hash algorithm if an option is set that is not available. this default may still be MD5 in many cases.

upon further review, it seems that some (perhaps many) distributions may still have MD5 set as default during the install. of course this can be changed by the installer.

collision attack weakness is important for digital certificates. the so-called preimage attack is theoretical. checksums can be generated in advance by a malicious software writer, but practically speaking for password encryption, this is not an issue if a sufficiently-long salt string is used, which seems to be the case.

.

jephthah 1,888 Posting Maven

although in retrospect, it's also probably better if i dont post after drinking.

Nick Evan commented: I agree :) +0
jephthah 1,888 Posting Maven

oops, i had a brainfart at the last minute and edited the code wrong. disregard the code i gave in #4, above. you had the basic form right the first time.

using your style (the style traditionally seen in many texts) it would look like:

x = malloc (T * sizeof(float*));
      for (i=0; i < T; i++)
         x[i] = malloc (S * sizeof(float));

using Salem's style it would look like:

x = malloc (T * sizeof(*x));
      for (i=0; i < T; i++)
         x[i] = malloc (S * sizeof(**x));

.

jephthah 1,888 Posting Maven

(1) means to not cast the return value of malloc. Simply write x=malloc (T*sizeof(float*)); instead of x=(float**) malloc (T*sizeof(float*)); . the cast is not required by the C standard and is redundant. this is at best "bad practice" and at worst can hide a serious bug if you didn't include the <stdlib.h> library.

(3) always include the <stdlib.h> library, otherwise malloc will assume the return of a type int regardless of your attempt to cast its return value. This can completely destroy the stack in some cases. It may not be the case for you, but is still in the "very bad practice" area.


(2) if you want to use the same code for C++ as for C, you invite more complexity that will require conditional compilation statements using #ifdef / #elsif / #endif methods.

Furthermore, the C language can certainly handle complex variables and perform FFT calculations, so this is not a reason for using C++. The <complex.h> library is standard to C99. You should be using this standard if you don't have a compelling reason not to. If you are forced to use C89, complex math can be handled using a third-party library.

(4) this is a style point, and diverges from the original problem. since you've already typed "x" as a type float**, Salem suggests you use sizeof(*x) instead of sizeof(float*) , and sizeof(**x) instead of sizeof(float) .

but a problem is you're not fully allocating your memory …

dr_michali commented: very helpful, thanks! +0
jephthah 1,888 Posting Maven

throwing stones is fun, but you need to at least support your off-handed criticism with some sort of context.

my summary was not meant to be an indepth historical review, but i'm pretty sure it's broadly accurate. so please correct me where i'm wrong.

jephthah 1,888 Posting Maven

Haha.

this guy, "cool_jatish", wanted his name changed probably because someone had previously caught him and called him out for being a Plagiarizing Loser.

i caught him and called him out just now begging for rep for his plagiarized posts in C forum.

so now he's either using his alias or got his buddy "vigasdeep" to downvote all of my posts.

LOL

what a loser.


.

jephthah 1,888 Posting Maven

dont bring your parents and teachers into this. they're already terribly upset at how spectacularly they FAILED with you.

seriously, <<snip, snip, snip & snip>>

jephthah 1,888 Posting Maven

jatish,

YOU PLAGIARIZING <<teddy-bear>>

if you're going to beg for "ratings" by stealing someone else's work, at least have the common courtesy to paraphrase your source material rather than posting it verbatim.

or do you think we're so stupid we can't find where you cut and paste from?

http://www.lisha.ufsc.br/teaching/os/exercise/hello.html


.


.

jephthah 1,888 Posting Maven

uncool_jatish,

YOU PLAGIARIZING <<flower>>

if you're going to beg for "ratings" by stealing someone else's work, at least have the common courtesy to paraphrase your source material rather than posting it verbatim.

or do you think we're so stupid we can't find where you cut and paste from?

http://www.linfo.org/create_c1.html


.

jonsca commented: The first rule of Rep Club is that you do not talk about Rep Club. +4
jephthah 1,888 Posting Maven

do you really think you have so novel an approach to STD DEV that needs to dig up a thread that is 3 years old?

because i assure you the OP hasn't been wainting for 3 years for your answer.


.

jephthah 1,888 Posting Maven

jesus christ already, i was being sarcastic.

cant you people read my facial expression?

:icon_frown: :P

jephthah 1,888 Posting Maven

who are you?

where did you come from?

why don't you have your own thread?

what the hell is that deprecated conio.h doing in your code.

check the forum rules before you post. the big fat sticky threads at the top of the C forum.

jephthah 1,888 Posting Maven

okay. but don't do it again.

:)

jephthah 1,888 Posting Maven

||=== perm, Debug ===|
|warning: return type of 'main' is not `int'|
||=== Build finished: 0 errors, 1 warnings ===|

i wonder why your program gives me warning....

jephthah 1,888 Posting Maven

I've never used libcurl. I'd love to help you, but all i can do is read the libcurl example that does exactly what you're looking for, and repeat what it says, but that would be kind of dumb and a waste of everyone's time, since you can just go read it yourself.

Aia commented: Best help ever. Just do it yourself! +8