WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Please answer my question. It was the only one I asked.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

any template i can draw examples from?

You own mind. What do you do when you need to do the task at your desk with paper and pencil. Write down those steps and find string methods that mimic them.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Try explaining what is wrong -- in detail.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

can any on explain me,the significance of talking i+=2??

It's a shorthand version of i = i + 2;

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Well, for one fflush(stdin); is wrong. See this.

Where is d defined and loaded?

With this little bit of code, we can tell nothing. And your description tells us nothing about your error. So, there's nothing to really say without details that explain better what the problem is.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i thought that maybe there was a way to read it as a string skipping the hyphens then converting it to an integer which is what i tried to do above but can't get it right

Not really, but you can read as a string and remove the hyphens, as Adak mentioned.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What are some of the methods that strings have that you can use?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

OK What gives?
1st post - a sh*tload of errors with no context
2nd post - code with no commentary, no questions, two days later
3rd post - worthless bump for no apparent reason
4th post - another worthless bump for no apparent reason

This thread is about to be closed...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

fgets() to read.
fputs[] to write.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague
// this is program designed to create Cd data base

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

//=============================================
//LINKED LIST USED FOR CREATING THE DATABASE CD
//=============================================
struct CD_type_node
{
   int CDnum;
   char title[20];
   int CDcount;
   struct CD_type_node* next;
};

struct Artist_type_node // to create a linked list of CD's
{
   struct CD_type_node CD_data;
   char Artist_name[20];
   struct Artist_type_node* next;

};

when i compile this is what it tells me: struct CD_type_node has no element Artist_name

how do i make the correct linked list and how do i create the array

Where is Artist_name defined? Is it in CD_type_node?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

When programming, you need to write the program (it's writing a program, not writing a code) in stages.

Finish what you have and output the data entered at the end.
Compile. Fix compiler errors. Repeat.

When the program runs correctly (that means outputs the data entered correctly) then add the next step in the program. In your case, calculate the GROSS pay.

Be sure to properly format your code (this info will help) and post with CODE tags (explained all over the site, you can't help but find them)

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

how would you do that? I tried declaring int c = 0; and after you input an operator, c is increased, and replace for(l = l;l > 0; l--) with for(int c = 0; c > 0; c--) but that just messes up the loop and the program doesnt run properly.

Answer #1) Then think about it longer and try again.

Answer #2) And that's was supposed to tell me what you did and I'm supposed to be able to tell you how to fix your code from this description?

Answer #3) Then try something else that will work.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

WaltP i did that but it didn't work...

I hate it when people say that. And my standard response is "then you did it wrong". I've been using that technique for 30 years and it works.

If you need help, generic non-information posts like you've been giving us is not going to get you any closer to an answer. Be specific. Why didn't it work? What code did you use?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Hello..
I searched the forum for a thread that explains how to rename your username, but I couldn't find any.. How can I assign a new name to my membership here?
Thank you.

And you didn't find one thread titled something like "Please change my username?" You certainly didn't look hard.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Every time you enter a 'variable' increment a counter.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I am trying to take a user input phone number and perform calculations on it as an integer of type long long.

Why? To see if the phone number is prime? This makes no sense because a phone number isn't a number, per se.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

You are making this so hard on yourself, and the responses you are getting don't help any.

1) You say the file is binary. So if you read the first byte of the file you should have 11111111 in the variable, not 01000110 or 01100110 (the letter F or f), correct?
2) If so, read the file properly. What you are doing is atrocious:

/* Open Packet File and Read it into buff */
    fp = fopen(pfile, "r");
    fseek(fp, 0L, SEEK_END);
    sk.sz = ftell(fp);
    fseek(fp, 0L, SEEK_SET);
    unsigned int buff[92];
    /*fread(buff, sizeof(buff), 1, fp);*/
    int c = 0;
    printf("%d\n", sk.sz);
    while (c != 62)
        {
            fscanf(fp, "%x", &buff[c]);
            printf("%x", &buff[c]);
            c++;
        }
    memcpy(&buff[sk.sz-1], "", 1);
    fclose(fp);

Make it simple:

/* Open Packet File and Read it into buff */
    fp = fopen(pfile, "r");
    byresRead= fread(buff, sizeof(buff), 1, fp);
    fclose(fp);

You now have your file read in, it's binary, and you can send it in binary. Is this what you need.

Or do you now need to convert the binary from the file into ASCII (HEX) characters so that your byte value 11111111 (binary) becomes 'FF' and the ASCII FF is sent?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

looking for advice).

Then why didn't you say so? Posting only code says "Look at my code! Ain't it great?" That's an ego-post. If you simply added "I'm looking for advice on making this code better" you would get more useful responses right away.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Then display the name you type in EXACTLY as the variable sees it. Is it character by character an identical match? Are there characters you don't normally see as characters in one of the names (like a trailing SPACE, TAB, CR, LF)?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I don't need to study it carefully. I already know how to help. And I did but you obviously didn't like it. Too bad, because it will work great towards answering your questions.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

1) Start letter at 'a'
2) Start the do-while loop
3) IF letter is not vowel
4) output the letter
5) increment the letter
6) end of do-while if letter >= 'z'

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sounds like an ego problem to me :icon_mrgreen:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

First off, see this.
Next, see this, too. It contains the information that describes your problem.
And this info is the most important of all.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

> yes that is a correct way u can proceed.........
Over a year late, and still you missed the better answer from ~s.o.s~

Let's add another 3 years to that.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Output your values at key points in your code to
1) make sure the variables contain the values they should
2) make sure the IF is processing the correct code

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

what is the code in timer if the user enter a negative number
a dialog box will appear saying that is invalid !!

You wouldn't put a dialog box in a timer.

NEED THE ANSWER ASAP
THANK YOU

We don't feel your emergency is our emergency. We will answer when we can.
AND DON'T SHOUT AT US!!!

faroukmuhammad commented: It seems like you've understood his question. Pls PM me with explanation. Thanks in advance. +4
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

My apologies but that's the way I felt on his reaction :)

Sorry....

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Other than it doesn't work properly, do you have a question? Or is this an ego-post?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I think that the question that so far has been unasked and needs to be is:
The file you are reading, is it a binary file with binary values or a text file with hex characters in it?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I'd stop using a site that a lot of people have errors on.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Before inserting data into the file, remove the commas and quotes. Then write the data. instr() might help.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What's strange in it?

Us. :icon_mrgreen:

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Well I thought making this rule would encourage other users to post more and be more active on DW. Does it make sense now?

No. How would it encourage more activity? If I want to have my user name changed one of two things will happen:
1) If I have to make 48 more posts, I will go elsewhere and forget DaniWeb.
2) If I have to make 48 more posts, I will post 48 lame-assed posts anywhere I can just to get my 50.

Alternatively, I all I have to do is ask, I would think "Gee, this is a nice place, they are helpful. I'll stay around and become part of this community."

jonsca commented: Only 47 more to go! Just kidding, WaltP, but that was too easy. +0
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Since you didn't bother to show us what you did, we have no idea what is wrong.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Count the wins and losses. The one with the higher win count wins.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Well im not using the program to write the file. Just to read it. Although I guess I could try to have it read the file, then write a new file as binary, then read the new file. But that just seems.... dirty.

That would be dirty, not that you've given us that information...

Then read the file and convert the 'string' into hex.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

I've seen some posts of users changing their usernames. But some of them are like below 50 posts.

So? What's the problem?

I mean why would they want to change their Usernames if they've just have less than 50 posts?

Because they decided they don't like their member name after 5 posts?

I mean they could have just make another account.

And you're suggesting that a bogus member be kept around simply because they can't have their name changed?

IMO, no member needs more than one account except a few top-level members.
No rank-and-file needs more than one. It has caused problems when they do. And what would a second account be used for? What do you suggest we do with the first account?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Write the file as binary instead of text.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Just thought I'd point out that 4 years ago this might have been an issue, but today this was a long-buried thread. Now you've resurrected a zombie. Thanks...

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Start at Narue's first post. The answer is there. You just have to look it up.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

4. How does it happen that people here misunderstand each other frequently?

We do it frequently for some serious fun and to confuse others.

Now I'm confused :confused:

Me too :D

See? It works!

You're not going to turn in yet another internetstalker, right? ("ohmygod, it's a woman on the interwebz!!"). Anyway, here's some global info about Daniweb and Dani.

See? That's what I mean by misunderstanding!!
So what if it's a woman?? I knew she's a woman (as appears on her image) from the very beginning, but I only thought she was a moderator.. That's the whole idea.
I dislike it to judge others quickly! I'm innocent :D
Anyway, thanks for the information.

A perfect example of misunderstanding. What Nick Evan said was a joke. It was "tongue-in-cheek" (look it up). The appropriate response would be "LOL! No, but I hear your sister is cute."

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yes, it can be solved in may ways. And why should someone find a different way when you hand the answer to them? They do not deserve a grade for your work. Please do not solve their problems. Help them solve it themselves.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Why not just set up a standard sort and use strcmp() ?

for i = 0 to MAX-1
  for j = MAX-1 to i+1 by -1
    strcmp(array[j-1], array[j]))
       swap if needed
WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Yes, zdep had posted badly formatted code to solve aomas98's problem. What grade do you think zdep should get for his effort? What about aomas98? Who should pass the class?

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Actually, please ask a question - one that can be answered, preferably.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

for the input above,

first call to strtok(), entry[i].IPDestinationNetwork = inet_addr (strtok (buffer, "\t")); returns pointer to the token before the delimiter(\t) of (i+1)th line (usually starting one).

and successive calls return pointers to the successive next tokens of each line (one while loop iteration for each line).

and so, entry[i].interface = strtok (NULL, "\t"); returns 4th (i.e., last) token of (i+1)th line.

As integers, floats, strings, characters, char*? What does it return? And are you putting the return into the correct variable type?

Methinks you need to write a test program to understand strtok() because you don't know what it's doing.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

What does strtok() return?
Given the answer to the that question, what does entry[i].interface = strtok (NULL, "\t"); do? Same for each call to strtok() .

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

Sorry, I was looking at the wrong code. My bad.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

i always include the stdafx.h, otherwise i get reminded to do so.

By whom? I have *never* used it and my code works fine.

WaltP 2,905 Posting Sage w/ dash of thyme Team Colleague

(sorry for the lack of braces, I tried getting rid of some for less confusion. Didn't think it would work but thought I might as well try :D)

1) Don't apologize, fix it. Add braces and you won't be sorry.
2) Removing braces makes the code confusing.
3) So put them back and repost.