jephthah 1,888 Posting Maven

hi and welcome! hope you're finding what you need :)

jephthah 1,888 Posting Maven

whaducallme?

:P

jephthah 1,888 Posting Maven

hi and welcome.

i kind of missed your point. are you saying you don't like people? that's cool i dont either. i'm just here trying to roll my post count past 2000.

anyhow, see you around. good luck finding what you're looking for.

jephthah 1,888 Posting Maven

dont worry, computers are just a fad. IT people will return to being sharecroppers.

:P

jephthah 1,888 Posting Maven

hi and welcome! hope you're finding what you need :)

jephthah 1,888 Posting Maven

hi and welcome! hope you're finding what you need :)

jephthah 1,888 Posting Maven

hi and welcome! sounds like a similar experience with many here. i remember DnD and 8" floppies too. I first played Star Trek game on a university mainframe in 7th grade. my first computer was I believe a Sinclair Z80. ugh random EMI would knock that thing out.

anyhow, hope you're finding what you need :)

jephthah 1,888 Posting Maven

hi and welcome! my dad always needs computer advice, too. i try to be patient with him, but it's tough to diagnose peculiar behavior on his computer long distance. i hope your son finds some time to help.

if he can't i'm sure people here will if you ask in the right forum.

jephthah 1,888 Posting Maven

hi and welcome! hope you're finding what you need :)

jephthah 1,888 Posting Maven

hi and welcome! hope you're finding what you need :)

jephthah 1,888 Posting Maven

hi and welcome! hope you're finding what you need :)

jephthah 1,888 Posting Maven

hi and welcome! hope you're finding what you need :)

jephthah 1,888 Posting Maven

you here to program, or sell houses?

jephthah 1,888 Posting Maven

i live in Seattle. welcome! :)

jephthah 1,888 Posting Maven

hi and welcome! hope you're finding what you need :)

jephthah 1,888 Posting Maven

hi and welcome!

jephthah 1,888 Posting Maven

hi and welcome!

jephthah 1,888 Posting Maven

hi and welcome!

jephthah 1,888 Posting Maven

if there's a thread that needs bumping, it's this one.

Keep Hope Alive!

Nick Evan commented: So you gave negrep because I deleted "me toos +0
jephthah 1,888 Posting Maven

i thought that was a good idea at first, but then I think about it for a moment, and i'm not so sure....

IMO, the few people who legitimately bump threads are newer users and they bump them b/c they misunderstand what was being discussed or the solution presented and are seeking clarification.

having a minimum post count would exclude the very people who are most likely be the few legitimate thread-bumpers in the first place.

it also imposes another layer of membership-status to segregate "probationary members" from the general population, as well requiring differentiating auto-closed threads from those closed due to specific abuse. That seems like a more substantial change to the site architecture.

an auto-close of all threads idle for more than 90 days would be easy to implement across the board. Moderators would have the ability to unlock a thread by request, per their discretion.


.

jephthah 1,888 Posting Maven

And how does that help with polygons, squares and circles? Does CODE:Blocks even have graphics? Turbo does.

Code Blocks has plenty of graphics. It provides integrated support for modern, cross-platform, industry-sanctioned graphic libraries, like GTK+, OpenGL, Win32::GUI, and wxWidgets.

not this archaic kid's toy of <graphics.h> used only by children, DOS Luddites, and university students from the Subcontinent.

jephthah 1,888 Posting Maven

as part of a project I've got to conjure up a programme,

"Conjure a program" ... Interesting choice of words.

Rather viewing your exercise as needing to write a program, you see it as an attempt to magically produce one from the ether.

And begging and wheedling has replaced the ritual incantations of yore.

MosaicFuneral commented: lol, Didn't notice those choice words. +3
jephthah 1,888 Posting Maven

I'm making a program that will attempt to lessen the effects of a flash drive when placed in an infected pc.

Basically it will make a folder named autorun.inf
then make a folder named "con" inside it...

oh, look, another skript kiddie trying to write a piece of malware.

i know you think you're clever, but this trick is like 15 years old, and won't crash computers with OS'es from the 21st Century.


.

jephthah 1,888 Posting Maven

for the life of me, i do not understand why ;) is rendered the same as :P ... it is really annoying. i use :P alot, and i don't really use ;) very much except for certain occasions.

now, everyone thinks I'm a ;) kind of guy when i'm actually just your basic sort :P chap.

knowutimean? :P


.

jephthah 1,888 Posting Maven

yes, good points.

i know about that particular rand method being not the best psuedo-randomizer. And i use the preferred method which you cited in my own programs.

but i figured he was just taught this particular "easy" way, and he already has enough new concepts to get a handle on before addressing more esoteric aspects of pseudo-random number generators than would be addressed Programming 101.

and i'm not sure why i used float. a voice in the back of my head was asking me the same question.

WaltP commented: Very good reasoning. KISS for new programmers. They don;t need the inner workings of perfection yet. RAND is good enough. +11
jephthah 1,888 Posting Maven

Narue is right in the other thread you link: she's talking about PRINTF

this thread is also right. it's talking about SCANF. as stated earlier -- much earlier, like 3 years ago -- use "%la" to scanf a double.

"printf" and "scanf" are different functions, they do not necessarily use the same format specifiers.

the fact that many of the format specifiers happen to be the same, is merely a coincidence that was apparently encouraged to trick unsuspecting new programmers.

.

jephthah 1,888 Posting Maven

if you want to randomize based on weighted percentages, then you need to roll a percentage, not a value from 1-6.

think of something like "rand() % 100 + 1" , which gives a number from 1 to 100.

or for more resolution, float pctRoll = (float) (rand() % 1000) / 1000.0 this gives a value between 0.000 and 0.999 with 1000 roughly equal increments.

i got interested in this problem, and i wrote a program to perform various combinations of variouis numbers of weighted and fair dice, and print results as a normalized graph

here's the relevant snippet, stripped down to remove extra I/O, just to illustrate the logic behind testing the percentages, and sorting each roll into counting bins.

This supposes a simple case where a die has shaved faces for the 1 and 6 sides; this would give the 1 and 6 a higher chance of landing compared to the others. I declare the 1 and 6 sides each have a 30% chance, and the remaining sides have 10% each

float   p[7] = {0, 0.3, 0.1, 0.1, 0.1, 0.1, 0.3};  // pct chance each side
float   pct;   // the random "roll" expressed as decimal percent
int     diceBin[7] = {0,0,0,0,0,0,0}   // counts occurances for each side

// note arrays size 7 indexes 0-6, skipping use of "zeroth" element
// to make corresponding array info to die rolls 1-6 more intuitive.

for (i=0; i<NUM_ROLLS; i++)
(
   pct = (float)(rand() % 1024) / 1024; …
jephthah 1,888 Posting Maven

I am getting Troubles to open Turboc C , i am having winxp sp2 i try to open Turboc C But getting errors error is ,,,,,, The NTVDM HAS ENCOUNTERED AN ILLEGAL INSTRUCTION. CS:0000 IP:0075 OP:f0 37 05 Choose 'Close' to terminate the application. plz anyone can shortout my problem

you've got two problems:

(1) Turbo C

(2) Posting in old, dead threads.


here's the solution to (1)

and here's the solution to (2)

jephthah 1,888 Posting Maven

Go to the principal or dean and explain to him that your instructor is handing out assignments without teaching the material, and he's forcing you to use a compiler that is 20 years old. You cannot learn adequately from a 20 year old compiler nor an instructor that won't teach what's needed for an assignment.

yeaaahhh ... i don't think that's really a good idea.

you're responsible for learning the material, regardless of how lousy you want people to think the instructor is. dont get me wrong, i don't doubt that you have lousy instructors. But judging from the majority of your peers that parade through here over the years, lousy instructors is obviously endemic to your country's educational system. Complaining about it will only get you marked as a troublemaker.

as for your crap Turbo C compiler, I'm certain the dean and the administration above him are responsible for foisting it upon you. I believe the highest echelon of your national university system is receiving kickbacks... er, i mean "incentives" ... from the Borland Corporation to perpetuate their shittiness all over the Second World.

anyhow, you got a program due tomorrow. so dont just stand there, do something.\\\


.

jephthah 1,888 Posting Maven

due tomorrow, huh? yeah, man, that's tough stuff.

well.... I reckon you oughtta get to looking up the <graphics.h> library in your Turbo C compiler.

jephthah 1,888 Posting Maven

Ah, good to know. Is that some Search Engine thing where you put your "Eat At Joe's" link in the post itself and that gets you more hits than if you had just put it in the signature itself?

'fake sigs' is just a catchall term for people who make stupid posts of the "me too" variety or presenting otherwise worthless or redundant information, just to present their signature containing links to their promotion site.

jephthah 1,888 Posting Maven

no, don't look up recursion. you're not even there yet.

what i'm saying is, your program is potentially doing this:

main
   prog
      nDice
         prog
            nDice
               prog
                  nDice
                    prog
                       nDice

just don't do that. it could be endless. it will be ugly.

and what i'm saying to do, is not a "stylistic" program

it's just plain and simple. keep your functions simple. write them cleanly. call them one at a time. return back to the caller (main) before calling another one.

this is a simple program, stop making it harder than it needs to be.

jephthah 1,888 Posting Maven
jephthah 1,888 Posting Maven

i didnt copy and paste my assignment,i wrote the code by my self but in the end iam having problem

yeah right. is that like when you posted:

below u will find a incomplete code,try 2 complete the code.

...

/* PLACE YOUR CODE HERE */

LOL. your incomplete code, hmm?

how 'bout u try 2 lie a little better.

we're not as dumb as you look.

.

Nick Evan commented: "we're not as dumb as you look" Nice :) +12
jephthah 1,888 Posting Maven

add a code in it so it work properly

yeah? and how far have you gotten?

i mean besides cutting and pasting your assignment here, as if we're your own personal homework-completion service.

.

jephthah 1,888 Posting Maven

First off, nice screen name :)

now to your problem: note how the function "NDice" is called from the "prog" function.

therefore , you shouldnt re-call your function "prog()" from within NDice.

it's like some sort of infinite recursion or something. like two mirrors facing each other.

this is how you should approach it. you need to make the functions clearly defined to do a certain thing and return to main.

main  
   call "NDice"
       NDice function gets number input
       if input error
           print insult and repeat 
       otherwise
           return number of dice
   
   call "RollDice" (argument : Number from NDice)
       RollDice function rolls number dice requested
       returns value of roll(s)

   "PrintFace" (argument : value from RollDice)
       PrintFace function print results as graphic dice face

end

so, rewrite your program with this simple structure in mind and try again

jephthah 1,888 Posting Maven

yeah?

so what?

jephthah 1,888 Posting Maven

*plbbbbbt*

jephthah 1,888 Posting Maven

Isn't that a classic mistake?

How is your preferred formatting different/better from these snippets?
http://www.daniweb.com/tutorials/tutorial45806.html

My thoughts on strtok here:
http://www.daniweb.com/code/snippet216569.html

your tutorial is very thorough. i wasnt aware or forgot about its existence. my code snippet use similar method and is certainly no better.

as for strtok, i doubt anyone here is getting user input from the console in a mulithreaded environment, but i probably do want to reconsider its general use since it's not reentrant-safe

not sure what you mean by classic mistake. the fact that i'm using strlen or sizeof as parameters for malloc? or that i didnt check the return pointer of malloc for possible memory error?

jephthah 1,888 Posting Maven

ugh, i just noticed something else really bad in this code:

#define s scanf
#define p printf

//...

p("Enter Day:");
s("%d",&t);

good lord, what's that about?

jephthah 1,888 Posting Maven


Exhibit A

Some bumps are worth reading.

um, I'm not seeing it there. I read those bumps, and now I want my 5 minutes back.

other than a bunch of me-too's and fake signatures, all i saw was one marginally-interesting note that the OP's code for Windows didn't port to Linux. Portability problems are hardly news. And it's not very insightful, since no one ever posted a solution to that issue.

in any event, a request that a thread be unlocked can be made by anyone who has something to add. it just forces them to be accountable for their posts, and only users with some amount of credibility will likely ever request threads be reopened.

and you'll notice that the thread in question wound up being closed anyhow, for the very reason that it became yet another magnet for worthless me-too and fake signature posts.


EDIT: but i will admit my previous use of any and ever was a bit hyperbolic. i should say :

"I rarely ever see someone contributing a meaningful bump to a thread that has been dead for more than three months. Even then, those few times are completely overwhelmed by the amount of me-too's, fake signatures, clueless hijackers, and other generally worthless posts "


.

jephthah 1,888 Posting Maven

true. it must've made sense at one time why i did it the long way but, a few edits later, i can't recall what it was.

:)

jephthah 1,888 Posting Maven

im still having a rather annoying problem! .... It never stops taking input and I still don't know a shortcut key to abort from the program.

because you're using getchar() to return into a char type, when it's return type is int. getchar() is a clunky function, and not well suited for getting strings. IMO, you should not use it. if you insist on using it, anyhow, then you need to use it with an int, not a char.

I say, you should use fgets() like Salem showed you.


.

jephthah 1,888 Posting Maven

it's not a homework .

Liar.

you posted a file called "LabAssignment.doc" . Which wants you to use lame-ass <graphics.h> librayr, Turbo C style, to draw some basic pictures.

Sorry, but we're not as dumb as you look.

come on ,, no one want to help me

ya think???

Salem commented: LOL +19
jephthah 1,888 Posting Maven

Oh, damn. you're right, it is broken.

my original was working by having the first fgets outside of the while loop with a second fgets inside. at the last minute, I condensed it all into a single do/while loop to make it more concise ... and neglected to perform a basic challenge to check my code

:icon_redface:

moving the strcpy to inside the do/while loop as a conditional fixes it, so it performs correctly.

thanks for checking it out and letting me know. how embarrassing.

here is the fixed version:

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

//*****************************************************************************************//
// GetUserInput()
//
// (c) 2010 by Jephthah and distributed for general use under the WTFPL licence
//
// purpose:gets user input, removes the newline, passes back results up to maximum
//         number of characters, flushes remaining characters from input buffer,
//         returns the number of total characters entered by user
//
// input:  maxStringLength is the maximum allowble characters to input by user
//
// output: returnStr, contains up to the maximum length of characters allowed that were
//         input by the user, any additional characters entered are lost
//
// return: total characters entered by user; caller should check that this value is equal
//         to or less than the maximum allowed to indicate valid string was input.  larger
//         value returned than was allowed by the input indicates characters were lost
//
//*****************************************************************************************//
int getUserInput (char * returnStr, int maxStringLength)
{
   char    *tempStr;
   int     totalCount = …
jephthah 1,888 Posting Maven

that wont solve most of it. most thread hijacking occurs in current threads. And while this is annoying, it is easy to deal with. simply tell them to make their own thread and ignore them afterwards. the issue self resolves.

what's more of a problem is how every other dipshit comes along posting an "answer" to a thread that is 4 years old. Their answers invariably suck, and will wind up appearing to be a solution to other people who find the thread in their searches later.

The Powers-That-Be seem to think that by leaving threads open indefinitely we wont deprive ourselves of some gem that comes along at some unspecified later date.

But I have yet to see any time anyone ever contributed anything remotely meaningful to a thread that has been dead for more than three months.

Simple solution, after 3 months of inactivity, auto-lock the thread. allow such threads to be unlocked only by a specific request from a member. that way, they'll really have something meaningful to request a closed thread be reopened.

and i wont keep getting stupid emails telling me that someone's replied to a thread i havent even thought about in 2 years.

jephthah 1,888 Posting Maven

okay, i get it. your code is fine. it's concise, but it doesnt protect user input and it doesnt validate range.

here is my corrected version. i believe it's pretty solid

Banfa, good job on calling me out on being sloppy. i should have followed through. the correction is simple: change 3 lines in the ConvertDateStringToVals from

if (ptr == mmStr)

to

if (ptr == mmStr || ptr != &mmStr[strlen(mmStr)])

here is the NOW BULLETPROOF(*) version that i should have posted in the first place

(* Nearly)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define MAX_DATESTR_LEN                16
#define DATESTR_DIVIDER_CHARACTERS     "/\\-_.,"  // allowable delimiters for month date year

int convertDateStringToVals (char*, const char*, int*, int*, int*);
int getUserInput(char*, int);

int main(void)
{
   char  dateStr[MAX_DATESTR_LEN];
   int   inputLen = 0,
         month,
         date,
         year,
         isInvalid;

   while (1)
   {
      do {
         printf("\nEnter Date String : ");
         fflush(stdout);
         inputLen = getUserInput(dateStr,MAX_DATESTR_LEN);
         if (inputLen > MAX_DATESTR_LEN)
            printf("string length %d, max length is %d, try again.\n\n",inputLen, MAX_DATESTR_LEN);
      }
      while (inputLen > MAX_DATESTR_LEN);

      if (inputLen == 0)
         break;

      isInvalid = convertDateStringToVals(dateStr, DATESTR_DIVIDER_CHARACTERS, &month, &date, &year);
      printf("   month : %02d\n   date  : %02d\n   year  : %d\n", month, date, year);

      if (isInvalid)
         printf("WARNING:  one or more fields are invalid.\n");
   }

   printf("exiting.\n");
   return 0;
}


//*****************************************************************************************//
// convertDateStringToVals()
//
// (c) 2010 by Jephthah and distributed for general use under the WTFPL licence
//
// purpose: converts each field of the datestring (month, day, year) into integer values.
//          fields may be separated by one or more …
jephthah 1,888 Posting Maven

Dad is sad.

Very very sad.

He had a bad day

What a day dad had.

jephthah 1,888 Posting Maven

goin on over in C, yes they are.

U Mad?

oh, yeah. we mad.

.

jephthah 1,888 Posting Maven

yeah, well, okay. your code is great. i'll study it and learn. thank you sir.

meanwhile how about deleting the other double-post shenanigans you posted in my name.

kkthx.