i'm planning on creating a program for reservations (ex. rooms)

by analyzing my problem,the things i don't know how to are:

validating the date and whether the room inquired is available or reserved for someone else

i'm guessing this will require me to create an output file,which i have no idea yet.

are those things mentioned complex?

>>are those things mentioned complex?
Yes, for someone who doesn't know anything about c++.

You need to learn the C++ language before attempting a program that complex. Learn to crawl before running full speed. Buy an introduction to C++ book and start studying at page 1, and do all the exercises at the end of each chapter. Don't skip chapters unless you already know the material from some prior programming experience.

Yes, for someone who doesn't know anything about c++.

well,it's safe to say that i'm not that someone.

i'm guessing this will require me to create an output file,which i have no idea yet

well,it's safe to say that i'm not that someone.

You're not ??? If you are that knowledgable why don't you know how to to file stuff?

lol

you said

Yes, for someone who doesn't know anything about c++.

anything doesn't mean everything.

though not really much,i still know something in c++

i haven't tried yet or have done something that requires me to use fstream,and that's what i meant by saying

i'm guessing this will require me to create an output file,which i have no idea yet

anyway,i'm guessing you can't help me because you're thinking i'm not showing some effort.thanks for the tip though.

so sorry if i asked. sure,i get it. you're good in programming :)

The things you mentioned are not difficult provided you know object oriented programming in C++. Do classes and inheritance well.

The things you mentioned are not difficult provided you know object oriented programming in C++. Do classes and inheritance well.

thanks for giving me an idea on where to start.

how can i output a character underlined? or set to bold face?

searched the net but i can't find anything about it

nevermind,i finished the prog.

to mods :

requesting for closure of this thread,thanks.

OMG that was pretty quick work! Guess you decided not to do bold and underling then.

>>guessing you can't help me because you're thinking i'm not showing some effort
Never said we can't help you -- just trying to find out how much you really know.

no that wasn't actually quick
took me almost 5 hours,mostly searching the net

it does not yet save/load from a file
but it's ok since it's only for school and alot has been applied in my prog that weren't even discussed yet

Never said we can't help you -- just trying to find out how much you really know

to be honest,it was just you i was referring to.
i didn't see it in any way that you were just trying to know how much i know.it was like more of you stating the obvious that i know less,and even said once that i know nothing XD

your posts didn't even gave me an idea on what i should apply in this program.

i can see that you know alot already,and i'd be grateful if you can help me some other time by giving useful hints atleast.

thanks anyway

char one[10];
char two[10];
int n;

cin>>one>>two;

for (n=0;n<11;n++)
{
if (strncmp(one[n],"xxxx xxxx",10)!=0 && strncmp(two[n],"x,xx xxx.",10)!=0)
     cout<<"Mismatch";
}

first,i tried without the for loop. the program runs but always says mismatch

then i tried having the for loop,.where'd i go wrong with strncmp that causes the error?

When you use cin to input a char array, all the characters after a space are ignored. For example if you enter "xxxx xxxx" in one, the actual value will be "xxxx". Try displaying it with a cout.

Also use

strncmp(one,"xxxx xxxx",10)!=0 && strncmp(two,"x,xx xxx.",10)!=0)

The what you are comparing is a char with a string.

I normally use a stdio function like gets() in order to input a string with spaces.

Edit: No need for loop either.

oh yeah,i was actually using gets()

i just typed that code here

here's my actual code

cout<<"Input date:";
gets(date);
if (strncmp(date,"xxx xx xxxx",11)!=0)
cout<<"\nInvalid format.";

my problem is that the input is always taken as an invalid format.
care to point out my error?

The problem here is that you are using strncmp to check the format of a date. Read help on strncmp and you will find that it is used to compare two strings.

The code is perfectly fine. What is does is check evey input with string "xxx xx xxxx" and not the format.

There is so much wrong here!!!

Both of you, please read this about gets().

This loop (reformatted for readability):

#
for (n = 0;  n < 11; n++)
{
    if (strncmp(one[n],"xxxx xxxx",10) != 0 && 
        strncmp(two[n],"x,xx xxx.",10) != 0)
    {
            cout<<"Mismatch";
    }
}

has the following problems:

1) the variables only contain 10 character locations and the loop goes through 11. The last value is therefore outside the array boundries. Only go to n < 10 2) one[n] is a character, not a pointer to a character array. strncmp() only works on pointers to array.

3) Even if the compare worked, the second time through the loop you'd start at one[1] and compare 10 characters. The last character compared is again beyond the bounds of the array. Next loop is one[2] so 2 characters are beyond the array. And so on.

Another couple more things you should probably read are the Rules and this post titled Read Me: Read This Before Posting

Comments
ty for gets
This article has been dead for over six months. Start a new discussion instead.