Narue 5,707 Bad Cop Team Colleague

All you're doing with the divide and conquer is breaking up the list into smaller lists, then putting the sorted smaller lists back together. This breakdown and rebuilding is an O(logn) operation:

0 1 2 3 4 5 6 7 8 9 A B C D E F
0 1 2 3 4 5 6 7
0 1 2 3
0 1
    2 3
0 1 2 3
        4 5 6 7
        4 5
            6 7
        4 5 6 7
0 1 2 3 4 5 6 7
                8 9 A B C D E F
                8 9 A B
                8 9
                    A B
                8 9 A B
                        C D E F
                        C D
                            E F
                        C D E F
                8 9 A B C D E F
0 1 2 3 4 5 6 7 8 9 A B C D E F

Now add to that the O(n) cost of sorting each partial list, and you've got the classic O(n * logn) complexity.

Narue 5,707 Bad Cop Team Colleague

>I know I'm supposed to use new and delete, but I really need to use realloc
malloc/calloc, realloc, and free don't fit well at all with objects of a class type. You really should forget they exist unless you really know what you're doing. Fortunately, realloc can be simulated in C++ with minimal effort:

#include <algorithm>
#include <cstddef>

template <typename T>
T *array_realloc ( T *p, std::size_t old_n, std::size_t new_n )
{
  if ( new_n == 0 ) {
    delete[] p;
    p = 0;
  }
  else if ( p == 0 ) {
    p = new T[new_n];
  }
  else {
    T *save = new T[new_n];
    std::copy ( p, p + std::min ( old_n, new_n ), save );
    delete[] p;
    p = save;
  }

  return p;
}

>//m->myclass() ?!
The safe way to explicitly manage object memory is with a custom allocator. Here is the basic usage with the standard allocator:

#include <iostream>
#include <memory>

class myclass {
public:
  int x;
public:
  myclass(): x ( 0 ) { }
  myclass ( const myclass& o ): x ( o.x ) { }
};

namespace {
  myclass DEFAULT;
}

int main()
{
  std::allocator<myclass> alloc;
  myclass *p = alloc.allocate ( sizeof *p );

  alloc.construct ( p, DEFAULT );

  std::cout<< p->x <<'\n';

  alloc.destroy ( p );
  alloc.deallocate ( p, 1 );
}

However, you're looking for the wrong solution to your problem. The right solution to not having realloc is to write your own realloc, not monkey around with non-portable ways …

Narue 5,707 Bad Cop Team Colleague

So basically you don't know how to write the program and want us to hold your hand (or do it for you). Sorry, but no go. You'll have to work a little harder than that for your code to count as proof of effort.

Narue 5,707 Bad Cop Team Colleague

>If u r programming in visual studio c++
I'm not programming in Visual C++ right now, so I guess I won't share my code with you. :icon_rolleyes:

>I WILL ALSO SHARE MINE.
Quite frankly, I'm not sure your code will be worth reading. But I can't verify that because I don't trust your Word documents that supposedly contain source code.

>OPEN IT IN OFFICE 2OO7
Good God. You're just like clueless users who send screenshots to tech support in a Word document. Offer plain text or everyone will assume you're trying to spread malware. Plain text is also easier to put in a text editor for compilation. Last time I checked, my compilers don't work well on .docx files.

Narue 5,707 Bad Cop Team Colleague

>delete (particles+i);
You can only delete addresses that were returned by new. particles+i will only reference such an address if i is zero. The whole of particles can be released in a single statement (no loop necessary):

delete[] particles;

Your code suggests that you're confused about the difference between a dynamic array of objects and a dynamic array of pointers to objects.

necrolin commented: Good explanation +1
Narue 5,707 Bad Cop Team Colleague

>It took you almost two hours to come up with that!?
Nope, I left and did other things, as my absence from the "Who's Online" list would have shown you. So much for your theory about me doing nothing but posting here.

>Well done you.
Yep, I'm awesome. I didn't even have to use dictionary.com to come up with the big words.

>Unsubscribing now, Bye!
You can't unsubscribe, but you can stop posting. Let's see how long that lasts. :) But I wish you luck in finding some dupe to break the law and get arrested for you.

iamthwee commented: For feeding the trolls +0
Narue 5,707 Bad Cop Team Colleague

>Hello Narue, Senior Bitch.
I changed my title just for you. :)

>Once again, thanks for your strange and now very angry post.
Rude, harsh, realistic, and mean are all appropriate adjectives for describing my posts, but not angry. I don't let emotion get in the way of expressing myself as intended.

>I am a business owner who has been left stranded by a useless web
>hosting company who have gone bust and taken my passwords with them.

Assuming you're telling the truth, that would place you in the latter of my two previously stated cases. It still doesn't change the fact that you've given no proof to substantiate your claim, and your request is against Daniweb's rules. Must we go in circles like this?

>I own my own very successful business and you are an angry
>little web weasel who does nothing but post sarcastic, unhelpful
>and rude posts on here to innocent, unsuspecting subscribers, in
>order to make yourself feel you have some sort of authority and
>control in your life.

Unless your business is psychological evaluation and dismissal of random online personalities given 500 words or less, I'd say your reaction is indicative of anger.

>Good luck and once again, Thanks.
My pleasure. If you have any further need of my unique brand of non-help for your illegal requests, don't hesitate to ask.

William Hemsworth commented: love the new sig & title ;] +0
Narue 5,707 Bad Cop Team Colleague

>Still don't understand 'I'm here to prove you wrong' part but no worries.
It's a signature, genius. It shows up on every post I make and is completely irrelevant to the content of my posts.

>Just so you know, I'll never use this site again so the threat of a
>deleted thread or a banned account really does not phase me.

Well, your attitude isn't exactly conducive for a long stint on Daniweb anyway ("damn the rules, I'll ask whatever I want", and all that), so do what you want and reap what you sow. I honestly don't care.

>Suggesting that I am trying to do something illegal is really very silly and childish.
No, it's actually quite a reasonable suspicion. Either you're a loser hacker who couldn't break into a piggy bank, or you're an extremely clueless business owner/IT professional for not ensuring that you have all of the necessary privileges for ownership of and access to the site. To protect the company in the case that you're the former, I prefer to assume the worst. If I'm wrong, all I've done is made you mad, and I can live with that.

>I think its obvious from my post that I had a genuine enquiry.
And I think it's obvious from your post that there are too many red flags for it to be genuine. You may be telling the truth, but I'm not willing to risk it.

Narue 5,707 Bad Cop Team Colleague

>I don't quite get you Narue, - 'bad things will happen'
"Bad things" meaning your thread will get closed or deleted, your account will accumulate infractions and may even be banned, and authorities may be contacted for suspected illegal activity.

>I'm afraid this is no help to me.
I'm not trying to help you. I'm explaining why I (and everyone else on this forum) will refuse to help you.

>I am trying to gain access to my own website, not someone else's!
If it's not under your name, you don't own it. If you don't own it, trying to gain access is hacking. Discussion of hacking is against Daniweb's rules. What's so difficult about that?

Narue 5,707 Bad Cop Team Colleague

I guess you can chalk this up as a lesson learned. What you're asking us to help you with amounts to gaining unauthorized access, discussion of which is against Daniweb's policies. I can guarantee that if you continue this line of inquiry, bad things will happen.

Narue 5,707 Bad Cop Team Colleague

>I assume she has a lot of other higher priority things to do
>than devote a lot of time/effort to something like this.

Those "conferences" that she uses to decide our fate without our input seem to be one such example. :icon_rolleyes:

Narue 5,707 Bad Cop Team Colleague

>Well then be more vocal about which features you use and how you use them.
Do you want a weekly status report about how we use the site? When you change things in a seemingly arbitrary way without asking for specific feedback from us, it's hard to give you the information you want. You could start a thread asking what we think of your ideas for future changes, but that would make far too much sense. A "conference" with some imaginary group of people who apparently know better than your highest volume users is clearly a much better choice. :icon_rolleyes:

>When you first visit DaniWeb, how do you begin your visit?
I have the main forum list bookmarked. The home page doesn't exist as far as I'm concerned, so any improvements you make there don't affect me.

sknake commented: agreed +0
Narue 5,707 Bad Cop Team Colleague

>Hopefully the overhead won't be so large as to outweigh the
>advantages of compessing my data into a binary format.

In my experience it's not significantly better or worse than text conversions in terms of overhead, so I don't think you'll find that to be an issue. The biggie is complexity. As your data gets more complicated, so does the conversion. For example, with integers you really only have to break up the bytes and make sure the ordering is consistent, but with floating-point you also need to break down the value into something normalized (take a look at frexp and ldexp) before considering storage. It all adds up and can end up being pretty hairy if you're not careful.

Narue 5,707 Bad Cop Team Colleague

>no. not as a metric with any meaning. I'm quite prepared to have my
>score asymptotically approach zero; anonymous aliases tend to go that way

That's odd, because people who don't care tend not to bitch and moan like you've been doing. :)

Narue 5,707 Bad Cop Team Colleague

>so if it really doesn't matter, then why is it such a cryptic process?
If it really doesn't matter, why do you care whether it's "cryptic" or not? Let's call a spade a spade and agree that you think this feature matters, you care about your score, and you want to understand how it works. Clearly the feature is written for people like you. You care enough to know that it's written well and completely, so it was (probably) "cryptically" designed to be useful for people like you while also preventing abuse.

Once again, I'll speculate that the points are weighted in the calculation. But if you're going to attack Dani (since I assume she's the one who wrote it) at every turn, she's more likely to ignore you as a troll and use her time productively.

Narue 5,707 Bad Cop Team Colleague

>How, without using a library written by someone else <snip> can I
>possibly write my model files on one platform, and load on another
>without either: using text files, or wasting space in my file?

Your problem is binary. Any binary output is inherently non-portable, and the only way to fix that is to normalize your output to a common format. This normalization is usually done with text conversions, but you can manually deconstruct and reconstruct your objects in a byte-wise manner as well. You seem to be leaning toward the latter, which means you need to pick a binary format, then when porting to a different system convert between that format and the system format when reading and writing your files.

Naturally this incurs an overhead cost of doing the conversion, so add that to your list of things to consider.

DarthPJB commented: narue continues to save us from programming hell! +1
Narue 5,707 Bad Cop Team Colleague

>this is a joke. I mean, seriously, did anyone here take any math classes in college?
It's a fair assumption that the points are weighted somehow. Are you interested in an answer or are you just here to bash things you don't understand? Because if it's the former, being a jackass is a good way not to get an answer.

Narue 5,707 Bad Cop Team Colleague

>maybe it was an unintended consequence of your awesomeness.
Good point. My awesomeness is very difficult to contain when I want to hide.

Narue 5,707 Bad Cop Team Colleague

I'd recommend solving the problem in a different way. Faking variant types with strings is fugly.

Narue 5,707 Bad Cop Team Colleague

>I was thinking stdin
The stream in question is whatever input stream you want to clean up in a line-oriented fashion, but yes, it was written with stdin in mind.

>Will it be something like this ->
Close:

printf("\n\n\tPress Enter To Continue ... ");
interactive_flush(stdin);
getchar();

The idea is for interactive_flush to clean up any extraneous characters in the stream. Note that the order you had won't work if there's more than one extra character. getchar will read the extra character, then interactive_flush will clear out the rest without blocking. The thing that causes the program to pause is the input request waiting (blocking) for the user to type something. If something is already there to read, the request won't block.

In the correct order, interactive_flush cleans out the extra characters and then getchar blocks.

Narue 5,707 Bad Cop Team Colleague

>there is nothing in C demands that TRUE = 1 and FALSE = 0.
Depends on the context. If you mean at the language level, then yes, relational comparisons are required to treat zero as false and non-zero as true.

>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

That's not a boolean context, and thus true/false is nonsensical. You don't have to describe device drivers to give an example of that kind of behavior. The main function does it, where 0 is a success code and non-zero denotes a failure code.

>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

Once again, not a boolean context. True/false doesn't apply here either.

jephthah commented: i stand corrected +5
Narue 5,707 Bad Cop Team Colleague

>I belive three, for(Iterator = something ; while-condition; do something to limit the loop ) ?
That's correct. Now take a look at your code and see if it matches what you just described.

Narue 5,707 Bad Cop Team Colleague

Segmentation faults come from trying to access memory that you don't own. In a linked list, this would be trying to dereference a null pointer, or access an invalid pointer.

>current_player = current_player->next = victim;
Hey look, and invalid pointer! You forgot to initialize victim.

Narue 5,707 Bad Cop Team Colleague

>Lines 124 and 132 contain the same two errors.
I'll answer your question with another question: How many clauses does a for loop have?

p.s. You also need to include the <string> header.

Narue 5,707 Bad Cop Team Colleague

>All of my teachers never reacted to my code like the way you people
>did but I guess that's because of their .. uh .. "inexperience".

This is distressingly common. A large number of teachers don't know C well enough to teach it. What they know is either dreadfully outdated or closely tied to the implementation being used at the school.

>No seriously, Narue, point noted about fflush(stdin)
Excellent. I'll even offer a reasonably portable solution that comes close, so you don't feel pressured to use fflush(stdin):

void interactive_flush ( FILE *in )
{
  /*
    Don't flush the stream if it's in an "error" state because 
    flushing clears the state. It might be needed elsewhere
  */
  if ( !feof ( in ) && !ferror ( in ) ) {
    int ch;

    /* Line-oriented: a newline or EOF marks the end of interactive input */
    do
      ch = getc ( in );
    while ( ch != '\n' && ch != EOF );

    /* The above loop could put the stream in an "error" state */
    clearerr ( in );
  }
}

I say it's close because it doesn't work well when the stream is empty. There's no convenient portable way to query the number of characters in the stream, or make a non-blocking read, so if the stream is empty this function will block for input. However, fflush(stdin) is generally called only when one knows that there are extraneous characters that need to be discarded, so …

Narue 5,707 Bad Cop Team Colleague

>Because once I press ignore, check the log file, see the record
>where the problem occurred, and fix the format, then I don't have a problem anymore.

Then you're parsing the file incorrectly. The issue still remains that your code is broken and needs to be fixed.

>which causes the i to go out of bounds.
Um, did it never occur to you to check the value of i before using it?

I honestly can't articulate how utterly retarded your solution to the problem is. Especially since you know exactly where the error is coming from and can reproduce it consistently. I can only hope you're not a professional working on wall street, in the medical field, or any other area where stupid programmers mean destroyed/lost lives.

Salem commented: ****applause*** +17
Narue 5,707 Bad Cop Team Colleague

>I've checked your IP to, just to make sure that you and Serkan are two different people
Don't tell anyone that Narue = jephthah too. :D

Narue 5,707 Bad Cop Team Colleague

>Jeez have guys heard of "the good samaritan act", I'm
>sure the person thought he/she was helping.

He was helping, and I'm sure he can be a valuable asset to the forum. But not correcting the mistakes of good Samaritans would be grievous negligence on our part.

>Did it require three senior posters calling this person down...
Whatever it takes to get the point across.

Narue 5,707 Bad Cop Team Colleague

>But as soon as I posted some of my code snippets
>here, immediately I got a stream of insults

If you're insulted by people correcting your mistakes, you need to adjust your attitude. Why? Because unless you're some kind of C demigod, you're going to make mistakes and people will correct them. Especially here, since Daniweb has a few members who know a lot about C.

>But it's not my fault, I've grown on clrscr() and getch() (due to my experience with C++).
clrscr and getch are just as non-portable in C++.

>Can anyone give me a link to such a compiler which does not support conio.h
Why not just avoid using conio.h? Every compiler has non-portable extensions and libraries. The best way to write portable code is to understand where the line between standard and non-standard is. There's not a perfect tool for doing that, you'll have to actually use your brain.

>Second is, I want a good book(pdf would be nice)
>about C DATA STRUCTURES. Even a site will do.

I'm partial to this one, for obvious reasons. Unfortunately, I can't recommend just one book on data structures because there are advantages and disadvantages to each one. I might be able to offer a recommendation or two if you specified which data structures interested you.

Personally, I think starting at DADS and using google for the interesting stuff will get you further than any …

Narue 5,707 Bad Cop Team Colleague

>scanf("%[^\n]s",&str1);
Scansets are a specifier on their own, not a part of the %s specifier. This format string reads up to a newline, then tries to match the character 's'. In your specific case it's not going to cause a problem, but if you try to convert anything after that, you'll get unexpected results.

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

Yes, that should do it. "It" being break the program by invoking undefined behavior. :icon_rolleyes: Please don't recommend poor practices.

>Try using gets(str1); and gets(str2); in place of scanf()
Seriously dude, you should learn a little more about C before trying to help people. You're pushing the worst possible options. Have you never learned that gets is 100% unsafe and impossible to make safe?

Narue 5,707 Bad Cop Team Colleague

>1. Line #8 works (at least my compiler doesn't comply), but line #12 is not allowed. Why?
Because the types are incompatible. It's legal to add a const qualifier as such:

int *p = 0;
const int *q;

q = p; // Okay

Note that p and q have the same type (pointer to non-const int). However, if you add a level of indirection, things get sticky:

int **p = 0;
const int **q;

q = p; // Bzzt! Type mismatch

Now const is a type qualifier, it actually changes the type of the object. As such, int* and const int* are two different types. Here's where your error comes in. When you declare a pointer to a type, the pointer is more or less required to point to an object of that type. So let's look at the code again:

// p is a pointer that points to an object of type int*
int **p = 0;
// q is a pointer that points to an object of type const int*
const int **q;

// const int* and int* are different types, thus
// q and p point to different types and are incompatible
q = p; // Bzzt! Type mismatch

>2. Line #15 is equal to int** const . I thought it should be rather const int**.
When you create a typedef, the type is set in stone. Any qualifiers applied after that apply to the typedef as a whole. For typedef …

Narue 5,707 Bad Cop Team Colleague

>restricted to use any of them, i should make my own one
That's stupid. You're not likely to invent a sorting algorithm that hasn't been invented before, and yours is much more likely to suck ass than one of the existing popular ones. I think you need to confirm what your assignment restrictions really mean.

My guess is that you can't use a pre-written sort function, but you can write your own function that implements insertion sort, selection sort, etc... The restriction being there to force you to write and understand the code rather than reuse something that somebody else wrote.

Narue 5,707 Bad Cop Team Colleague

>On June 21 2009, Narue disappears off the face of the Daniweb planet.
As she does occasionally due to real life concerns and lack of interest. This is common knowledge, and a running joke, I think.

>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"

Maybe he got hit by a bus. :icon_rolleyes: Or maybe it's crunch time for a project and he doesn't waste his non-work hours around here. Not everything is a conspiracy, you know. Then again, maybe Tom Gunn is Daniweb superhero Narue's mild mannered alter ego. When the n00bs attack, Tom Gunn steps into a telephone booth and changes into Narue so that she can swoop in and save the day with a sound verbal thrashing. Da da da daaa, NARUE!

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

Shortly after a "where is Narue?" thread in which I expressed interest in going old school again. Cause and effect.

>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.

You mean around the time I stepped down as super mod and took …

Narue 5,707 Bad Cop Team Colleague

>I only posted because I agreed with the OP about our instructor.
>Then you proceed to call me a sock puppet...

Exactly. I call it like I see it, and if you have a problem with that, you're welcome to kiss my ass. :)

>That's why I say you have a poor attitude.
It's always amusing when some wannabe net nanny joins Daniweb and immediately tries to tell us how to do things. This is a meritocracy. Until you've earned the right to have an opinion, nobody gives a damn what you think.

So as to avoid driving this thread off topic for too long, please PM me if you want to continue being verbally abused. kthxbye.

Narue 5,707 Bad Cop Team Colleague

>Why is there no way to delete a post?
You mean besides preserving the flow of threads, disallowing malicious deletions, and helping people who visit the forum long after a thread has ended? I guess it's a restriction designed to annoy you personally. :icon_rolleyes:

>Anyway, the point is people make a mistake.
And getting burned for making a mistake drastically decreases your chances of making the mistake again. Instead of bitching about it, you should learn from the experience. I see one of two lessons here:

  1. You really did deserve negative rep. You need to consider the behavior that encouraged the rep and change it if you don't want to get more.
  2. You didn't deserve negative rep. You need to realize that some people are just jerks, and there's nothing you can do about it.

If I make a mistake, I suck it up and move on. That's an attribute of maturity. I highly recommend it. Trying to backtrack and sweep your mistakes under the rug is childish and unproductive.

>What is the reason for a reputation score?
It's a fluff feature that means absolutely nothing. Don't get your panties in a twist about it.

>As far as I am concerned, there should be more people that are
>trying to solve threads and give solutions to coding problems.

The majority of threads get answers, at least in the forums I frequent.

Narue 5,707 Bad Cop Team Colleague
std::string name;

// Get the name...

std::ifstream in ( ( name + ".txt" ).c_str() );
Narue 5,707 Bad Cop Team Colleague

>Sry i was trying to quote from this answer and i accidentally gave -1 at the answer.
I fixed it for you. Now it's back at 0. :)

>Can u write the de-allocation of memory in 1 in code pls??

// Allocate
T **p = new T*[ROWS];

for ( int i = 0; i < ROWS; i++ )
  p[i] = new T[COLS];

// Release
for ( int i = 0; i < ROWS; i++ )
  delete[] p[i];

delete[] p;
Narue 5,707 Bad Cop Team Colleague

>Kindly let me know of alternatives of how I could solve this problem.
You're not actually appending to the file, you're appending to lines in the file, which amounts to inserting into the file. Unless you're using a system with record oriented files, your two best options are probably the following:

  1. Store everything in memory until you're ready to save, then overwrite the file.
  2. Write a new file with your changes, then replace the original file with the new file.
Narue 5,707 Bad Cop Team Colleague

GetData and GetSize are called on objects that are qualified as const. In such a case the compiler has to assume that both of those functions modify the state of the object, so it disallows the call. You can fix it by qualifying the two member functions as const since they don't actually modify the state:

unsigned GetSize() const
{
	return n;
}

void* GetData() const
{
	return v;
}
Narue 5,707 Bad Cop Team Colleague

>how do i send this data using this func
Either change the size of your buffer, or call the function multiple times. It really depends on how SendDataReq works.

Narue 5,707 Bad Cop Team Colleague

>I am not certain where to start.
Then you should consider switching your major. "I don't know where to start" is equivalent to "I'm not cut out for programming".

>1. Write a C program that only lists all files in the current
>directory and all files in subsequent sub directories.

This is a simple program. Do a man for opendir, readdir, and closedir, and stat. You can recursively go through the directory tree.

>2. Write a C program to print the lines of a file which contain a
>word given as the program argument (a simple version of grep
>UNIX utility).

This can be written using standard C (no Unix-specific code). Do a man for strstr. Presumably you know how to read lines from a file. :icon_rolleyes:

>3. Write a C program to emulate the ls -l UNIX command that
>prints all files in a current directory and lists access privileges etc.

Do a man for stat.

>4. Write a C program that gives the user the opportunity to
>remove any or all of the files in a current working directory.

This can be done in standard C too. Do a man for remove.

Narue 5,707 Bad Cop Team Colleague

Are you a complete idiot?

Ezzaral commented: There's a non-zero chance. +0
Narue 5,707 Bad Cop Team Colleague

You want to compare with the current index, not counter. The value of counter is the number of legit values in the array. Using it as an index in an array that was not completely populated is extremely likely to be undefined behavior. This is the algorithm:

int min = array[0]; // Start with the first element

for ( int i = 0; i < counter; i++ ) {
  if ( array[i] < min ) // Compare with the current element
    min = array[i]; // Replace with a smaller value
}

cout<<"The smallest value is "<< min <<'\n';
Narue 5,707 Bad Cop Team Colleague

>It should be considered valid, but it's not.
Direct comparison of floating-point values is risky because some values might not be exact, and the comparison will produce an unexpected result. You should take care to use a fudge factor when doing this kind of comparison:

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <float.h>
#define N_MIN 0.001
#define N_MAX 0.1

int fltcmp ( float lhs, float rhs )
{
  if ( lhs < rhs && ( rhs - lhs ) >= fabs ( rhs * FLT_EPSILON ) )
    return -1;
  else if ( lhs > rhs && ( lhs - rhs ) >= fabs ( lhs * FLT_EPSILON ) )
    return +1;
  else
    return 0;
} 

int main()
{
    float num;
    printf("Enter a number.\n");
    scanf("%f", &num);
    if(fltcmp(num, N_MIN) < 0 || fltcmp(num, N_MAX) > 0)
    {
        printf("Invalid.\n");
    }
    else
    {
        printf("Valid.\n");
    }
    return(0);
}
Narue 5,707 Bad Cop Team Colleague

>Here's all of it...
Wrong. First, you assumed too much about the question. Second, you assume that the structure you posted is universal. Third, you didn't explain squat about it. Someone who doesn't understand how stdio works internally isn't going to suddenly become enlightened simply by seeing the members of FILE. I had to actually implement the damn thing to get a good feel of the "whole concept".

Narue 5,707 Bad Cop Team Colleague

Good god, can't you come up with something a little more specific?

Narue 5,707 Bad Cop Team Colleague

The >> operator is default delimited by whitespace. If your strings need to contain whitespace, use getline instead.

FYI:

>ifstream plainText(inputPath.c_str());
>ofstream cipherText(outputPath.c_str());

This won't do jack because inputPath and outputPath are presently empty strings. You need to open the file after figuring out what the path is. :icon_rolleyes:

>while (!plainText.eof()){
This is a bad idea. The eof member function only returns true after reading past end-of-file. In other words, your loop will probably run once more than expected. Because getline returns a stream reference, and stream references have a conversion for the stream state, you can do this to fix the problem:

while ( getline ( plainText, plainLine ) ) {
  // ...
}
BobRoss commented: Thank you!!!! +1
Narue 5,707 Bad Cop Team Colleague

If you don't expect the first character to actually be whitespace, you can use "%*s". Otherwise, because %s ignores leading whitespace, you would need to use an exclusion scanset of whitespace:

fscanf ( in, "%*[^ \n\t\r\f\v]" );
Narue 5,707 Bad Cop Team Colleague

>All we know that PI = 22/7.
Apparently not, because those of us who are correct know that PI < 22/7. Further, because PI is an irrational number there's no combination of x and y where x/y = PI.

>But how and why it is 22/7 rather other fractions?
PI is the ratio of a circle's circumference to its diameter. 22/7 is a reasonable approximation of that ratio.

Narue 5,707 Bad Cop Team Colleague

>Is C++ the easiest language ever?
No, it's one of the hardest.

>anybody know how to help?
Nope. Your question is about as close to incoherent as they get. Can you try to make more sense?