jephthah 1,888 Posting Maven

what is the function that can be used to count the number of days that a thread has been dead and buried?

jonsca commented: Money +1
jephthah 1,888 Posting Maven

^ that may work for you in this instance, but it's not standard C, and will not be portable. thats a realtime clock library that is often found on linux machines, but is not guaranteed by the C standard.

for standard C that will work everywhere, use the functions "time()", "localtime()", and "asctime()" from the time.h library.

this will print human readable time of your local timezone.

make sure you understand the "time_t" time type and the "struct tm" time structure.


.

jephthah 1,888 Posting Maven

nothing wrong with turbo c for beginners, except that they post their uncompilable mess on forums like these, and desperately hope for someone to help them.

i could probably help them with basic questions, but tehn i see all these TurboC-specific libraries that wont compile, and i just glaze over and lose all ability to care.

jephthah 1,888 Posting Maven

I know this is using C. But if i was using the stdlib.h to use C in C++ ..... trying to find a simple way to add two hex numbers together but in C++;

I know this is the C forum, but if it were the C++ forum, it would be a different forum.

I also know this thread is 1-1/2 years old, but if it were a new thread, it would be a different thread.

jephthah 1,888 Posting Maven

Would you believe there are still a few commercial manufacturers who still use computers that run ancient MS-DOS 6.X operating system. ....

i know and have worked at companies like that too. but it's a case-by-case situation, usually there is some reason (however shaky) that they keep those legacy systems in place, usually for manufacturing concerns.

what i'm talking about seems to be systemic to the entire university/tech school system in India: every single undergrad uses Turbo variant, and several have told me that their instructors will fail them if they use a different compiler.

what kind of educational system would insist on (or even provide as the default) such a broken-down piece of crap and hold it as a standard?

jephthah 1,888 Posting Maven

I wondered where that went... it seemed like earlier today it was there. did it just get killed today?

jephthah 1,888 Posting Maven

interesting. i'd like to hear more about that.

i've always suspected it was due to kickbacks or "donations" from Borland to university admins to enforce exclusive use of their crap.

if i really wanted to be a conspiracy nut, i'd say it was a malicious effort by Borland and western corporations to gimp India's students so their country's tech industry remains just competent enough to staff tech support call centers.

but that might be stretching it....

jephthah 1,888 Posting Maven

your question doesnt make any sense.

and we dont just hand out solutions to every beggar that comes along, anyhow.

why don't you just use the security settings built into IE to whitelist/blacklist websites? reinventing the wheel is usually a waste of time, especially when you obviously don't know what you're doing.

jephthah 1,888 Posting Maven

don't everyone all start talking at once....

jephthah 1,888 Posting Maven

is this an assignment for a C++ class? or something you're really trying to do in real life?

if this is a real application, I'd say you're using the wrong language and you should seriously consider Perl. Perl was made for this problem.

you'd have a complete solution that parses validated email addresses from a file in about 4 or 5 total lines of code.


.

jephthah 1,888 Posting Maven

how are the number in the fields generated. they do not look random.

jephthah 1,888 Posting Maven

I don't understand. Nobody in the US uses this crappy compiler with it's non-standard libraries. No one in the Western World seems to use this. even in second world countries in central and south america, they don't use this.

so how is it that Borland seems to have a complete lockdown on universities and tech schools all over India and a few Eastern European and Asian countries?

From what I've heard/read, kids in India are supposedly threatened with failure, if they attempt to use another compiler other than their institutionally-enforced Borland/Turbo/Whatever Piece Of Crap it is that they have.

how did this come about? maybe i'm a conspiracy nut, but, well... it seems like a conspiracy.

jephthah 1,888 Posting Maven

let me know what operating system you're using. I assume Windows XP.

If you happen to be using Turbo C on Linux (unimaginable, really, but i have heard tales), this will change the way we approach the whole problem.

jephthah 1,888 Posting Maven

Hello
I converted the source code of the English language. I program in php and mysql. I am programmed much of C and C + + and some of the things I know how it should be done in C and the other part of C + +. But I have to do this task only on C but I do not know how? For this I have done in C + +. I know that is not right to mix the two languages for programming. If someone can help me to do only the task of C.

it's nice that you converted your code comments to english -- not required but perhaps more people will not be easily confused or distracted.

and some people here will point to your use of "fflush(stdin)" and "gets", which are big no-no's, but you have a more fundamental problem.

your problem remains that you have a very implementation-specific program here, full of non-standard C code due to your choice of compiler, TurboC.

as a result, i can not compile or run or debug your program. and most people who would be able to help you, will have the same issue. Turbo C is just not used by professionals in the modern technical society. Microsoft Visual C++ and GCC have free compilers and are the industry standards, and there are many high quality free development environments that are compatible with these.

there's just no reason for anyone to …

jonsca commented: Nice response +1
William Hemsworth commented: yup +5
tux4life commented: Nice response +6
jephthah 1,888 Posting Maven

i thought the Big Bang was actually the Egyptian god, Ptah,who masturbated and his ejaculate became the universe.

jephthah 1,888 Posting Maven

i would like to subscribe to your newsgroup.

jephthah 1,888 Posting Maven

I dont really understand the logic here? Thats is gonna get into an infinite loop!

i believe you're right. she's trying to find when there's only one player left, but that isnt how to do it. the size of the structure is constant and greater than 1... i think the end condition should be when the current player's 'next' field points back to the current player.

but i believe narue called the source seg fault: the non allocated pointer.

i'm also suspicious of the line 29. i think the for condition should be i<(n-1) : the number of players, minus the 'first player' that was already allocated. But in any event, that's not related to the seg fault.


.

jephthah 1,888 Posting Maven

So I am trying to malloc the array in the following way, but I am still getting segfault errors if I try to access which means I am probably not doing it correctly. This is incredibly frustrating! Am I completely off base?

it looks right to me... although you know it's no longer necessary to cast calls to malloc since ISO C was introduced. And it's recommended that you don't.

as for the seg fault error, did you try adatapost's suggestion?


.

jephthah 1,888 Posting Maven

C99 support variable length array

damn C99

:icon_redface:

jephthah 1,888 Posting Maven

why don't you create a new thread, rephrased in a manner such that you have a question that can be both understood and answered.

just sayin'

jephthah 1,888 Posting Maven

holy indentation, batman! :icon_eek:

seriously, dude, i can't even look at that. you've got to properly indent that mess.


.

jephthah 1,888 Posting Maven

i dont know what your actual assignment says. but in any event you just can't use integer variables to declare array sizes. unless you dynamically allocate arrays, they are allocated at compile time and those variables are meaningless until runtime.

you can do something like this:

#define BLOCK_SIZE     4
#define NUM_SETS       2
#define BLOCKS_PER     1

int i, j;
cacheItem cache[BLOCK_SIZE*NUM_SETS][BLOCKS_PER];

//...

as to passing arguments, either pass constants as arguments directly, or use the #define'd constants as globals, or assign the local variables to the #define'd constant values before passing them.

you could also use "sizeof" to determine the size of the arrays during runtime.

finally, just a note, your "block size" and "number of sets" as separate entities seem to be a meaningless distinction -- you never use them individually, you always use them multiplied together.


.

kvprajapati commented: Good suggestion +6
jephthah 1,888 Posting Maven

line 29.

you can't use variables to declare an array.

jephthah 1,888 Posting Maven

Hi everybody,

so I need to give this huge proyect on monday.

well, you better get busy.

i need to write a program in c

okay, here's a start:

#include <stdio.h>

int main(void)
{
    // start coding here


    return 0;
}
jephthah 1,888 Posting Maven

it's not embedded, it's TurboC.

yes, it is toilet paper. and now, after two years, you just floated it back to the top of the bowl. Thanks :-/

jephthah 1,888 Posting Maven

I see so could this be a solution

you're using that "for" loop to do the function of a "while" loop. your 'counter' variable is meaningless. if you want a while loop, then just use a while loop.

another problem is that the two pointers are often not going to be pointing to '\0' (NULL character) at the same time. the memory locations after the terminating NULL are not guaranteed to be NULL. you could wind up with a big mess.

what happens when one string is longer than the other? one will be Null and one will not. why would you want to keep looping in that case? get out and determine which string ended. that string will be alphabetically "before" the other. e.g. "internets" comes after "internet"

If I subtract both strings would that just give me which word is longer? and I need them in alphabetical order.

no. you would get the difference between the two addresses, which would be meaningless.

"strlen" will give you the length of a string. since you're having to write your own "strcmp" function, you may not be allowed to use the <string.h> library. doesnt matter, though, because if you just use the while loop and jump out when the first string hits the end (the NULL character), you don't need to know the string lenght.

jephthah 1,888 Posting Maven

it would be nice to promote the latest threads which have not been replied to. This way people can see their thread still being alive instead of having to bump it for to keep on the first regular page.

f their thread is not being replied to, then there's probably a reason. like their question sucks, and they need to reformulate their question.

continuing to nudge them would only cause all the trash threads to float on the top like so much Atlantic sewage on the Jersey shoreline.

anyhow, we can easily see what threads are not replied to by the BIG RED ZERO in the replies column.

people who care about making sure all posts have been replied to in their forums, can easily click "next" page if they really need something to do.

Ezzaral commented: Completely agree. +0
jephthah 1,888 Posting Maven

maybe it was an unintended consequence of your awesomeness.

maybe it was an experiment, or a vanity project.

jephthah 1,888 Posting Maven

I'd recommend that you reconsider your design. This kind of thing suggests that your design is awkward and ill-suited to C.

curious what you would recommend. C++? or rethinking the entire approach and not attempting to type cast at all?

.

jephthah 1,888 Posting Maven

I was wondering whether we can even post our algorithms if the thread starter didn't even post a single code or algorithm of his/her own.

there's no cut and dry rule, but you should put forth roughly the same detail and/or effort as the poster did in asking the question.

considering what the OP asked, i think c0d3x's response was perfect.

if the OP comes back with some code, then s/he can get more detailed response.

jephthah 1,888 Posting Maven

A high profile member may want to participate without being quite so high profile all the time.

which is exactly what i was thinking of when i discovered the unusually precise timing coincidences in their appearance/disappearance, and the uncanny posting similarities between them

that Narue is an admitted covert alias user, only increases the evidence against her and "mister" Gunn.

.

jephthah 1,888 Posting Maven

what does "No self-defined functions used" mean? that doesn't make any sense, so it seems to me you could just do this:

int compare_strings( char *str1, char *str2)
{
    return strcmp(str1, str2);
}

but that would be retarded to put a wrapper around a library function, and since this is (obviously) your homework assignment, i'm sure that's not what your instructor is looking for.

so you need to look at each character in each string and compare them against the other. if they all match, return zero. if they dont match, how do they not match? if the letter in str1 comes before str2 (alphabetically) then that letter in str1 will have a lower ascii value than the letter in str2

now, how are the letter stored in the strings in the first place? here's an example:

str1 = "Hello World"
str2 = "Hello Werds"

*str1 = 'H' = 0x48 (dec 72)
*str2 = 'H' = 0x48 (dec 72)

(*str1 +1) = 'e' = 0x65 (dec 101)
(*str2 +1) = 'e' = 0x65 (dec 101)

(*str1 + 5) = ' ' = 0x20 (dec 32)
(*str2 + 5) = ' ' = 0x20 (dec 32)

(*str1 + 7) = 'o' = 0x6F (dec 111)
(*str2 + 7) = 'e' = 0x65 (dec 101)

of course you dont cycle through each element using +1, +2, +3, etc. you will use the ++ increment operator to increment the …

xavier666 commented: The last C syntax is nice +0
jephthah 1,888 Posting Maven

my only problem is my search and delete and the search and edit...please help me. i've attached my unfinished program here:

you're going to have to be a little more specific. what's your question?

jephthah 1,888 Posting Maven

so you've posted your assignment.

what is your question?

jephthah 1,888 Posting Maven

Hi BGSPACE,

welcome to the forums. thanks for using code tags and explaining your problem.

my problem with your code, is that you've got quite a mix of different environments, you have some non-standard C, and you've also got some C++ functionality mixed in there.

the odd combination of <conio.h>, <sys/types.h> and <dirent.h> looks like you're using Borland's Turbo C. this is a terrible non-standard version of C and has been deprecated for going on 2 decades in most of the western world.

also, your use of <vector> is a C++ structure that is not C-language at all, and makes your program neither C nor C++ but some unfortunate hybrid.

Because you're using Turbo C with all it's non standard libraries, I'm afraid I can't help you. there's just no way i can even begin to compile your code on any standard C or C++ compiler. for the same reason, I suspect you will have a difficult time finding anyone else here who can help you beyond just visually inspecting your code for obvious errors.

the fact is, Borland's compilers are really crap and there are very few serious programmers who would ever use them. you will forever have difficulty as long as you continue to use it.

i strongly recommend that you toss it out and learn to use any of the following: GCC, MinGW, CodeBlocks, Bloodshed Dev C++, and/or Microsoft Visual C++. each of these are industry standard and are free, …

jephthah 1,888 Posting Maven

back off Mister 666, the poster has done nothing wrong.

there is no requirement that within the body of the code comments and output text be in English.

the forum rule you cite is to discourage pidgin english and leet speak, not to enforce some anglo-centric worldview. a large percentage of users here are NOT native english speakers.

bgspace does NOT have to rewrite his/her code to conform to your sensibilities. if you cant understand C code, then you need to quit "helping"

jephthah 1,888 Posting Maven

well, i learn something new every day.

The problem is named after Flavius Josephus, a Jewish historian living in the 1st century.

According to Josephus' account of the siege of Yodfat, he and his 40 comrade soldiers were trapped in a cave, surrounded by Romans. They chose suicide over capture and decided that they would form a circle and start killing themselves using a step of three.

Josephus states that by luck, or maybe by the hand of God, he and another man remained the last and gave up to the Romans.

jephthah 1,888 Posting Maven

another feckless attempt to steal teh fectorial codez.

jephthah 1,888 Posting Maven

there is nothing in C demands that TRUE = 1 and FALSE = 0. macros and constants are only what you #define them to be.

depending on what variation of the C environment you use, you very well may have TRUE defined as 1 and FALSE defined as 0 for you. you may have one or more libraries with an .h file that has the following:

#ifndef FALSE
#define FALSE               0
#endif

#ifndef TRUE
#define TRUE                1
#endif

you may even put that in one of your own .h files.

Sinkula's link, above, warns you to be careful about relying on conditional evaluating something to TRUE (1) when you shouldn't. at best, it can be redundant and unnecessary, at worst it can cause a very hard to find bug.

furthermore the typical concept of FALSE = 0 and TRUE = 1 (or non-zero) is often invalid for many situations, or at least does not follow the assumed perspective. for instance, i write device drivers following a popular convention that defines the return value of the function as:

zero     = success
negative = failure/error code
positive = warning/event info

other functions such as I/O likewise will use negative values as failure/error codes, and may have positive values be the successful return of valid information. these positive values will often likely not be 1, but be some larger number.

so back up and revisit your assumptions on what TRUE and FALSE mean to you. you might …

jephthah 1,888 Posting Maven

Why is there no way to delete a post?

there is. it's done by using the "EDIT" button, and is available for the first 30 minutes after you post.

it wont take the fact that you posted away, but if you've said something irretrievably stupid, you just change it to be completely blank. who will ever know?


I apologize that I got worked up over it. ... I was really surprised when I saw that "I had shameless behavior in the past."

those phrases are generic and are blindly based on your total score. your score briefly dipped below zero, because you caught the ire of a couple senior members. the phrases themselves are amusing tidbits that are even more meaningless than the numeric value.

just call your linux/windows faux pas an oversight and be done with it. obviously you weren't reading carefully, because you obviously know the diff btwn linux and windows. if everyone who ever made a stupid statement was drummed out, there'd be no one here. I'm embarrassed to review some of my past posts, some of the stuff i've said is unbelievably dumb.

the whole rep system arbitrary and subject to the whims of people with high scores. it's a 'good-ol-boy' network of the highest order, and has been thoroughly gamed by the old-timers even if unintentionally so.

the rep system is constantly being criticised by someone, is often under review, and has been teh subject of a recent …

jephthah 1,888 Posting Maven

consider the following:

typedef struct 
{
   char name[20];
   int memory;
   int time;
   int files;
} proceso;        // proceso is a "type" of struct
                  // defined as having the above elements
 
proceso titulos[MAX_TITLES] = {       // titulos is an instance of proceso
   {"Doom3", 500, 4,5},               // declared as an array
   {"Hades", 100, 2,1},               // and containing the following values
   {"Word" , 50, 1,1},
   {"FIFA" , 10, 3,1},
   {"Doom2", 400, 5,2},
// ...
// question:  how many is "MAX_TITLES" ?
};

//....
// print fields like so

for (i=0; i<MAX_TITLES; i++)
{
   printf("title name: %s (%d MB)\n",titulos[i].name, titulos[i].memory);
}

// etc...
jephthah 1,888 Posting Maven

man, when i was in the Navy, we had our BMI regularly measured. it used some other measurements like neck and waist but essentially the same.

there was a guy who had a BMI of 8 or 9. many of us had BMIs of 15 or so.

the criteria that <18 is underweight and <15 is starving is bullshit. they've changed the standards to match the average american fatbody .

jephthah 1,888 Posting Maven

Overzealous, much?

touche :P

sometimes something seems like a good idea at the time. then later on, not so much.

jephthah 1,888 Posting Maven

[you're] a stalker with too much time on his hands.

:'(


.

jephthah 1,888 Posting Maven

why do you think the following "solution" in the C-language forum is a good solution?

The problem is that you have not flushed stdin. Put fflush(stdin); before the scanf . That should do it.

-- /forums/post1069864

... because you actually gave it a green cookie with the comment:

Well said. - adatapost

i realize you don't post in C very much. I guess there's a reason for that. perhaps you could review a bit before endorsing "solutions"?

Just a suggestion

thanks

jephthah 1,888 Posting Maven

I added mine because I thought I would be nice and supply you with an answer. Because also, your posted "solution" that "works" in Mandriva is not a viable solution: it's a platform specific workaround and an example of sloppy coding.

in any event, why are you complaining for getting help? you should be grateful that we're not letting you run with scissors.

fact is, Xavier666 is full of bad advice in a number of threads and I'm tired of seeing his "solutions". This one especially irks me because a moderator endorsed it.


.

jephthah 1,888 Posting Maven

We've already infracted two members on grounds of stalking and minor harassment.

OMG, ~s.o.s~!?

overzealous, much?

:icon_rolleyes:

jephthah 1,888 Posting Maven

Dear raghuhr84,

please disregard everything Xavier666 has said. anyone who suggests flushing the input buffer or using gets() has no business instructing anyone in the C language. (I'm also concerned as to why a moderator on this site (adatapost) would endorse his "solution" by giving him a green dot, but that's another issue.)

regarding your problem, I would recommend that for basic input, you use the "fgets()" function. "fgets" will get the input then you will parse it afterwards. "scanf()" has a lot of powerful functionality, but is susceptible to user error and can cause a lot of grief.

int main(void)
{
    char str1[100];
    char str2[100];

    printf("Enter 1st string\n");
    fgets(str1, 100, stdin);

    printf("Enter 2nd string\n");
    fgets(str2, 100, stdin);
  
    printf("1st string is %s\n", str1);
    printf("2nd string is %s\n", str2);
 
    return 0;
}

note this will have some problems if more than 99 characters are entered for a string. try entering 100 or more characters for string 1, and see the result.

this case can be accounted for with a few extra lines of code. i'll leave that for you to figure out.


.

jephthah 1,888 Posting Maven

What is this obsession with Tom Gunn, anyway? We already had a whole thread on this months ago

part of the wide-ranging conspiracy is that the original thread was locked down. the mods don't think you can handle the truth.

and FTR, the obsession is with Narue, duh. but i digress: Tom Gunn is Narue.

Q.E.D.


One of the reasons I don't outright confirm or deny the accusation is because it's so much fun to watch everyone speculate

well you sure did spend a lot of keystrokes attempting to explain away the mountain of circumstantial evidence against you ;-)

and by "everyone" I mean jephthah, since he seems to be the only one who really cares

don't confuse being my able to recognize your shenanigans with the source of the warm fuzzies you're feeling. sure i love you ... but you still can't call me Serkan. :D


.

jephthah 1,888 Posting Maven

so... for 5 solid years, our C/C++ Warrior Narue has been a regular poster averaging 4 posts per day (4.08 to be exact).

On June 21 2009, Narue disappears off the face of the Daniweb planet.

new guy Tom Gunn had joined Daniweb five days previously, on June 18. Tom Gunn hits the ground running. He maintains a posting rate identical to Narue's (3.99 posts per day) and almost immediately becomes a C/C++ superstar. For the next 5 months, he logs 681 posts, and racks up an incredible 1400+ rep points. Yes, that's right: 1479 reputation points in less than 5 months.

Then on 13 November, Tom Gunn abruptly disappears as quick as he appeared, vanishing into the ether with not so much as a "by your leave"

and less than 5 days later, Narue has fully resumed her previous posting frequency, picking up right where she left off.

Narue may point out that she had been posting during the time between 21 June and 18 November. But i point out that it was highly sporadic, sometimes just one post a week, sometimes up to a month without posting at all.

In fact, she posted absolutely nothing at all from June 21 to July 17... July 17th just so happened to be the very day that I posted this thread about Tom Gunn's uncanny resemblance to our C/C++ goddess

I submit this for your consideration. :)