jephthah 1,888 Posting Maven

sorry you're having so much trouble. i'm afraid i have no idea about converting old borland graphics libraries. i avoid ever using them in the first place.

at leas this can serve as a warning to others, to stay clear of developing on Turbo C, especially with the antiquated graphics or conio libraries. there are libraries that attempt to recreate these functions for other compilers, but they always have problems.

if you stick to coding in standard C, you'll avoid thes problem. if you need to go outside the standard, then use modern portable libraries and modern compilers.

jephthah 1,888 Posting Maven

think ardav meant that other people's references to the old username will remain within the body of the text.

like i change my name to "joe schmoe" and all my old posts are now listed as being "joe schmoe" but other people's posts will still be addressing me as "jephthah".

it will cause consternation when internet archaeologists of the 22nd century attempt to reconstruct our "original intent"

there will probably be a schism between scholars over the Daniweb Apocrypha

WaltP commented: Good description... +0
jephthah 1,888 Posting Maven

most other sites have the courtesy to close their stale threads. they leave them available for archive purposes, but not allow them to become magnets for spammers, trolls, and other assorted retards.

allowing flotsam and jetsam from the internets to collect around old posts only serves to make the Daniweb site look incompetent . Passers-by from google links see our popular "Solved" threads with ridiculous "answers" and/or insipid commentary as final posts, sometimes pages worth.

if that's the kind of image you want to project, that of "inmates running the asylum", then keeping the threads open forever is the way to go.

jephthah 1,888 Posting Maven

I don't know why, but every time i see this thread title Memento comes to mind. maybe it's because i just cant remember any other titles.

Ha ha. get it? I cant remember them!! LOL. you know, remember any ...

oh, never mind.

jonsca commented: Wait, what do you mean? +0
Aia commented: Look at the tatoo in you arm. ;) +0
jephthah 1,888 Posting Maven

please check the dates before posting. youre responding to someone who posted over two years ago, who was posting to someone else from four years prior to that.

nobody cares about this thread or is paying attention, all its doing now is cluttering forum space and wasting time.

jephthah 1,888 Posting Maven

I shall never think of it either.

And let us never speak of it again.

jephthah 1,888 Posting Maven

You could be right there. Replace Google search with DaniWeb search in that equation. Maybe this is something Dani could take a look at when the current site update stuff is out of the way.

or maybe she could "take a look" at auto-locking old threads, that can only be re-opened upon legitimate request to a moderator.

would be easy to implement, will quit appending bullshit answers to solved threads, quit wasting moderators time locking and deleting the swarms of one-off "me toos" and "gimmetehcodez" posters.

it would also save the rest of us from crafting detailed responses to the OP, thinking it's a current thread, only to find out afterwards that the damn thing is five years old. i don't know how many times i've done that, it's really aggravating.

diafol commented: here here +0
Ancient Dragon commented: Agree +0
jephthah 1,888 Posting Maven

NIIT course programs are weak, their faculty is mediocre and lacking in research and scholarship. the 4 year programs keep you there for 2 years longer than you need to be, at overpriced tuition rates to jack up your bill. of course they don't care that you'll run yourself into debt with student loans... they get paid.

make no mistake, NIIT is a for-profit business. like all for-profits, they are focused their bottom line -- which is selling their product to you at the best profit margin they can manage.

meanwhile you'll be in debt and working at a call center trying to scramble your way out from the masses who are all competing against you for the better design jobs.

what kind of job you get is going to be based solely on your effort, not the overpriced and overrated 4-year tech degree from this college, when a 2 year tech degree will teach you everything you need to know to get an entry-level job in IT.

IT is not rocket science. It's not medicine. It's not even engineering. so don't waste an additional 2 years mucking around with dance classes and development of eastern philosophy in between programming "hello world" on an antiquated Turbo C compiler.

what you need to learn is how to configure network switches and splice CAT-6 ethernet cable, write shell scripts and set up a LAMP environment. et cetera. this is stuff that you will learn at any reputable …

jephthah 1,888 Posting Maven

This is my last reply for this thread. Google it up you come to know everything!!!!

says the guy who knows everything through Google. yeah, Turbo C. rock on, dude. :icon_rolleyes:

it's clear why you spend your time in here giving "Google advice" rather than in any structured programming language forums solving code problems .

seriously, Chichiro, you'd do well to stay away from NIIT unless you're looking for a career in telephone tech support

.

jephthah 1,888 Posting Maven

you can copy any file, whatever the type or extension.

just open the source file as a binary file and use a while loop to copy each byte one at a time to the destination, until the EOF charater is found.

see fopen(), fgetc(), fputc(), and feof() in the standard C library <stdio.h>. that's all the functions you'll need, though you'll probably want to include error checking with ferror().


.

jephthah 1,888 Posting Maven

in the ... link they are saying, user should definitely NOT [use fflush(stdout) to clear the output buffer.]

that webpage is a joke. a bad joke. they actually instruct you to use gets() as an example of "safe code". this right there tells me they're talking out their ass.

for example here jephthah gave a solution where he used fflush after printf and mentioned // printf did not have newline, need to flush

if you don't print a newline, but want the line to display to the terminal, you should use fflush(stdout);. Your system may not need this, but some systems will not print text to the output buffer until a newline is found or the buffer is otherwise flushed.

Narue has explained it better than i can. i'm only commenting here because my name was dropped :icon_wink:

jephthah 1,888 Posting Maven

"isPrime" is just a flag that gets set or cleared to indicate whether or not the current number being tested is prime.

if isPrime = 0, then it is not prime.
if isPrime = 1, then it is prime.

here is the process by which it works:

the outer for loop for (number=lower;number<=upper;number++) tests each number within the range desired. before we start testing each number, we set isPrime = 1; which is to say that we will assume each number is prime until we later find otherwise.

so then we go into the second (inner) loop and test each of the appropriate divisors against the number. IF the number is found to be divisible by any one of the divisors, the number is "not prime" and so we clear isPrime = 0 and break; out of the inner loop -- there's no point in testing any more divisors, since the number is not prime.

once we're out of the second (inner) loop -- whether it's because we (a) found a divisor that evenly divided the number and broke out early, or (b) because we checked all the divisors and none of them evenly divided the number -- the determination of the number being prime or not will be reflected by the value of "isPrime".... if "isPrime" is 1, then the number is prime. if "isPrime" is 0, then the number is not prime.

we then index the outer loop to the next …

jephthah 1,888 Posting Maven

look i'm just going to give this to you, because it's obvious you're trying, and you really need to get some better coding practices.

study how i've modified your code, noting a few key points:

-- the second (inner) for loop should not be testing divisors across the entire range, but only up to a number less than the number being divided. in fact, this "maximum divisor" should not be more than half the number being tested, because it's meaningless to test divisors larger than half of the number being tested, and will just add unnecessary computations.

-- you need to test *each* of the appropriate divisors, and *none* of those divisors should be evenly divisible into the number in order for that number to be considered prime.

-- name your variables with meaningful names

-- comment your code heavily, explaining each fundamental block.

-- quit using <conio> functions like "clrscr" and "getche"

#include <stdio.h>
#include <stdlib.h>

int main(void)
{
   int lower, upper, number, divisor, maxDivisor, remainder, isPrime;

   printf("\nEnter Lower Number of Range: ");
   fflush(stdout);  // in case lack of newline blocks buffer
   scanf ("%d",&lower);

   printf("Enter Upper Number of Range: ");
   fflush(stdout);  // in case lack of newline blocks buffer
   scanf ("%d",&upper);

   printf("\nPrimes Numbers in this Range are:\n\n");

   // cycle through each number within the range of values requested

   for (number = lower ; number <= upper; number++)
   {
      isPrime = 1;  // assume each is a prime unless found otherwise

      // for …
Xufyan commented: ummaah... +0
jephthah 1,888 Posting Maven

it wasnt working to begin with. try to run your original code with the same range.

AD just fixed some of the blatant loop error to keep it from repeat printing. the problem is your choice of variables in which to base your loops, and the fact that you print the number as a prime on the first instance of it not being divisible by some number. just because 9 is not divisible by 2, doesnt mean that it's prime. obviously, it's divisible by 3. yet, as soon as it's found to not be divisible by 2, you print it as being prime.

your problem is also the way you name your variables. a, b, c, d, e, f... could you be any more cryptic? this is bad practice that lends itself to unintelligible code that is difficult to debug. and it will be full of bugs, because the programmer himself cant understand what is going on.

.

jephthah 1,888 Posting Maven

hi....everyone


i am new here and welcome daniweb forums....

great! Welcome! Im glad youre here!

Because we need more people to bump 6 year old threads to promote their spammy sig links!

:) :) :) :)

jephthah 1,888 Posting Maven

because we sure do need all these new users posting half-assed, me too, or completely wrong "solutions" to multi-year-old threads that had already long since been resolved.

like this
and this
and this
and this
and this
and this

I could go on, because that's just a sample from the past 10 days or so in C. i havent even started on other forums.

Salem commented: Careful, you might trigger the non-existant link-spam detection s/w when you post too many links ;) +0
jephthah 1,888 Posting Maven

glad it helped.

side note, you can write any kind of file you want, the question is will application "X" understand it.

.CSV file just means "comma separated values" and this extension is typically opened by Excel on default. ally comma-separated values (strings or numbers) will appear across the columns, newlines will move down to the next row.

A true Excel file is an .XLS file and you can not very easily write a valid .XLS file without going through a lot of contortions with the Windows API and OLE Automation.

you could have also easily written a .TXT file and just opened it in any basic text editor such as WordPad or TextPad.


.

jephthah 1,888 Posting Maven

change printf to fprintf and write to a .csv file

FILE * fp = fopen("mydata.csv", "w");  // opens file to write ("w"), using the FILE pointer "fp"

//...

printf("16 Bit:\n\n");
  for (n=0;n<numberOfValues;n++){
    fprintf(fp, "%.4x\n", rand16());   // prints to the file, using the file pointer "fp"

//...

fclose(fp);  // close the file after you're done

}

oggiemc commented: straight to the point once again, very helpful poster +1
jephthah 1,888 Posting Maven

man, you're starting to sound helpless. the link i gave you gives every single time.h function and prototype. a basic search will find examples such as this:

/* localtime example */
#include <stdio.h>
#include <time.h>

int main ()
{
  time_t rawtime;
  struct tm * timeinfo;

  time ( &rawtime );
  timeinfo = localtime ( &rawtime );
  printf ( "Current local time and date: %s", asctime (timeinfo) );
  
  return 0;
}
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

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

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

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
Salem commented: An appropriately cryptic, yet useful response. +20
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

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

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

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

jesus christ already, i was being sarcastic.

cant you people read my facial expression?

:icon_frown: :P

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
jephthah 1,888 Posting Maven

OOPS.... ^ thats wrong ^

Line #2 should read 2-- and if (b > c) note also, that the "else if" pseudo-code in line i have numbered as #6 is implied, would not be coded, and actually will result in an "else" statement that logically meets the condition b >= a , so this conditional method doesnt note the condition when two values are tied for the largest value.

other than that, the following should be correct:

(a > b) ? ( (a > c) ? a : c  ) : ( (b > c) ? b : c )

---1---   ( ---2---  -3- -5- )    ---------6---------
                                   ---7---  -8- -10-
  if      ( and if  then else )  (       else         )
                                 (    if   then else  )
Xufyan commented: thanks alot . xufyan +0
jephthah 1,888 Posting Maven

where you think you are? some sort of do-my-homework-for-me service?

i'd tell you to go to the Java or C++ forum, but they'd just laugh at you if you post this "gimmetehcodez" question.

when you're ready to show the work done, point out where you're stuck, and ask a coherent question, then come back.

jephthah 1,888 Posting Maven

yes. if you're on windows OS, download and install a free full-featured C development environment, with a modern compiler that is standard compliant. I recommend CodeBlocks, make sure you get the download with the "MinGW" compiler.

Microsoft's Visual C++ compiler (MSVC) is also quality, but the free (express) version is not full-featured. you will need to pay for the full package.

when someone at NIIT tells you to use Turbo C, laugh in their face and ask "a 20-year old obsolete compiler? whatever on earth for?"

if you have more specific programming questions, come to the C forum. many people there to help.


.

jephthah 1,888 Posting Maven

yeah, sorry, but I'm just totally confused, and I have to ask "why"

why does an institute that ostensibly has the purpose to train students in the latest technology, why do they insist their students use 20-year old obsolete compilers?

I mean, what's wrong with these people? Can we get an instructor or administrator from this place to explain their rationale? I really want to hear how they can justify teaching these deprecated and non-portable concepts when modern standards-compliant development environments are freely available?

It's like some kind of bizarre conspiracy.

jephthah 1,888 Posting Maven

wait, what?

someone on the internets is being a jerk?

hold the phone...

jephthah 1,888 Posting Maven

They will start you career from Turbo C & C++, bcoz there you have all the basic things that you have to learn about the programming.

that is such a bad joke. these poor students, they come to our C forum in droves, completely clueless and perpetually on the wrong track. And they're totally helpless to remedy the situation because their instructors literally FORCE them to use this antiquated, non-standard, non-portable Turbo C crap.

you'd think that a university that charges so much, would not require their students to use a compiler and development environment that has been obsolete for going on 20 years Yet they insist that they do so, and wont let them use one of many freely available modern C compiler that adhere to the standards

when you say "Start your career" you really mean "sabotage your career".. or "retard your career"

unless, as i suspect, you're just churning out telephone Tech Support operators for your mega Call Centers, then I guess it doenst much matter.

i pity your students. what a waste of money.

.

Salem commented: Well said +0
jephthah 1,888 Posting Maven

is this one of the universities that forces their students to program in Turbo C++?

jephthah 1,888 Posting Maven

We used Turbo C in our programming and we need to do our project using Turbo C only.

That's a lie. Your instructor is an incompetent dolt. If he says otherwise, send him here.

Do everyone a favor, especially yourself, and use a modern development environment such as code::blocks with the MinGW compiler.

anything you build using a modern compiler that complies with the C standard (such as the link above) , will work on your instructor's retarded choice of a 20-year-old dried turd of a compiler. the reverse is NOT true, however, so don't waste your time building garbage on a decrepit toy.

do it right.


.

Aia commented: For a neverending anti-turbo-c campaign. +8
jonsca commented: "Beautiful" imagery +3
jephthah 1,888 Posting Maven

there's no reason why you should be afraid of <stdlib.h>. it won't bite you. you should not use <conio.h> that library has been obsolete for 20 years. most modern compilers do not use it.

as to "how to randomize", here's the simple answer: if you want a random number from 1 to 'n',

int number;
number = rand() % n + 1;

there some are problems with this method, but you don't need to worry about them for now.

one thing, this will generate the same sequence of "random" numbers each time you run the program. if you want a different sequence of random numbers each time the program is run, you'll need to "seed" the number generator, using "srand"

jephthah 1,888 Posting Maven

wow... self-righteous much? :icon_rolleyes:

speaking of "Leaders" and being incapable of "independent thought" do you get your rants from Glenn Beck or Rush Limbaugh, or do you just synthesize Fox News talking points in general?

jephthah 1,888 Posting Maven

when you declare a prototype, like in line 4, you declare the function type, function name, and argument types, like you did: void printtable(int x); , this must match the definition of the function, which you have down on line 46.

but when you *call* the function in the program, like at line 9, do not include the function type or argument types, so you just call it like so: printtable(10); .... where the number "10" (for example) could be any "int" value and will be passed to the function.

when you get to the function definition, starting at line 46:

void printtable(int x)          /* Function definition */
{
    for (x=0; x<10; x++) 
    {
        printf("%d",x);
        printf("n");
    }
}

you see that whatever value passed in from the function call (line 9) will come into this function via the argument as "int x"... the purpose of this would be to have a value that could then be used for whatever purpose you intended within the function.

HOWEVER, what you are doing is not really correct, or at least is not what is intended. once you get to the function, you reassign "x=0" in your FOR loop, thereby losing whatever value was passed in.

it seems to me that you really intend to have "x" be the upper limit of your for loop, so that it counts out "x" numbers. change your printtable function to something like this:

void printtable(int x)          /* Function definition */
{ …
jephthah 1,888 Posting Maven

ah, grown men loitering on playgrounds late at night.

well... I guess that's okay then.

oh wait, no it's not.

jephthah 1,888 Posting Maven

I was always brought up that cow tipping was a standard rural recreation event. So it was surprising when my mom argued with me today that it is now considered rude to suggest that provincials will engage in an evening of cow tipping. I have nothing against cow tipping, but to me it seems a bit unpleasant for the cow and possibly dangerous. Since cow tipping is apparently so widespread I don't see any logic behind this supposed change in attitudes about it. Being an urbanite I might be out of the loop. Maybe it's just a hoax. Thoughts?

jephthah 1,888 Posting Maven

yeah, well you little punks need get your ass inside at night and do your homework.

Ezzaral commented: :D +0
jephthah 1,888 Posting Maven

Eff it. i'm gonna learn to fly. i'll figure out how to walk, later.