tux4life 2,072 Postaholic

Fanta and crisps :P

tux4life 2,072 Postaholic

It's pretty much logical your while statement isn't working correctly, if you use the '=' operator in an expression, this means that you're assigning something, it means not that you're comparing something, if you want to compare, you should use the '==' operator so while (r[B]=[/B]'s') would become while (r[B]==[/B]'s') :)

tux4life 2,072 Postaholic

:) nope thux4life,it doesn't compile, that's why I'm asking for help

If it doesn't compile, you should also paste the whole error message your compiler is giving in this thread, by the way, it isn't thux4life, it's tux4life (correct and it will save you 1 keystroke as well :P)

tux4life 2,072 Postaholic

Unportable code alarm!
You're including conio.h, this isn't a standard library file
iostream.h is not a C header, it's a C++ header, so you posted your code in the wrong forum
Aaargh, the terrible void main() , it's evil, replace it with int main() (read this ).
This is not C code, this is C++ code (this means that you've posted in the wrong forum), consider using new style header files (if your compiler supports it), so:

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

would become:

#include<cstdio>
#include<conio.h>
#include<cstdlib>
#include<cstring>
#include<iostream>

:)

Note: This is definitely (rubbish) C++ code (mixed with C), cout is an object, and C isn't an object oriented language :P

jephthah commented: gawd yes, what a mess. i too hate conio. +10
tux4life 2,072 Postaholic

>Is it ok and help with the errors?
Does it compile? Then it's syntactically correct.
Does it run and give the expected output? Then you're pretty sure that you haven't made a mistake :)

tux4life 2,072 Postaholic

Take a look at the corrected code and at Ahmed_I's post :)

#include <iostream> 
using namespace std;
int main ()
{

	int faq_choice;
	[B]char faq_YN;[/B]
		
	cout << "\t\t\t =================    "<<endl;
	cout << "\t\t\t     ||   || || ||    "<<endl;
	cout << "\t\t\t     ||   || || ||    "<<endl;
	cout << "\t\t\t     ||      || ||    "<<endl;
	cout << "\t\t\t \\   ||         ||   "<<endl;
	cout << "\t\t\t  \\  ||              "<<endl;
	cout << "\t\t\t   \\ ||              "<<endl;
	cout << "\t\t\t    \\||  J-Otaku-Air "<<endl;
	cout <<endl;
	cout <<endl;

       do
       {

	    cout << "Welcome to the Frequently Asked Questions (FAQ) area."<<endl;
	    cout << "Bellow is a list of frequently asked questions."<<endl;
	    cout << "Choose the number of the required quest then press Enter to show the answer."<<endl;
	    cout <<endl;
            cout <<endl;

	    cout << "Q1. Should I reconfirm my flights, hotel or car reservations?"<<endl;
	    cout << "Q2.What happens if the airline has changed my flights?"<<endl;
	    cout << "Q3.Do you deliver tickets to other countries?"<<endl;
	    cout << "Q4.Do you deliver tickets to a hotel/business or alternate place"<<endl;
	    cout << "other than my home?"<<endl;
	    cout << "Q5.What if my tickets are lost or stolen?"<<endl;

	
            cout <<endl;
	    cin  >> faq_choice;
	    cout <<endl;
	    cout << "Are you sure you want question number "<<faq_choice << " ?(Y/N)"<<endl;
	    cin  >> faq_YN;
	    cout <<endl;
	    cout <<endl;
	

            if ((faq_YN=='N') [B]||[/B] (faq_YN=='n'))
	    {
               cout << "If you are not happy with your choice, then please choose another question"<<endl;
	    }

	    if ((faq_YN=='Y') [B]||[/B] (faq_YN=='y'))
	    {
	
		cout<<"Here is the answer."<<endl;
	    }
	
	
	    switch ([B]faq_choice[/B])
	    {
	    case (1):
		cout << …
tux4life 2,072 Postaholic

Sorry for the stupid questions, but I'm beginner in Java...

There's nothing wrong with being a beginner, and by the way: questions aren't stupid, as long as you learn something of it :)

tux4life 2,072 Postaholic

this is the whole code that i have been able make.

You're wrong, there are missing some parts, for example a main function, and the rest of the 'remove()' function, and maybe some other stuff too :P

tux4life 2,072 Postaholic

>If you want to compare the password you type with some pre-determined password then do something like this
Correct, but the strange thing is that he doesn't want to do that :D

tux4life 2,072 Postaholic

it asks the user to type in something, then it goes through everything the user could have possibly typed in then it prints it to the screen. i know theres no point for it but its just pracice.

But if you start with an uppercase 'A' then you won't process all the possible things he could have typed in, by the way, this could take a very very long time, if you want to check all possible combinations (and you're doing something else wrong as well), I would try something else :)

tux4life 2,072 Postaholic

>14: ISO C++ forbids comparison between pointer and integers
Yep, the error message is correct, since the name of an array can be treated as a constant pointer to the first element of that array.

How can we avoid this?
Well, can you first tell us what your program is intended for?

tux4life 2,072 Postaholic

tux4life i don't get anything you wrote but i realize that you are learned in programming . so i would request u to please help me in removing the data from the file created in my program please.

In that case we'll need your whole code :)

tux4life 2,072 Postaholic

Yea, siddhantes, I'm also tired of doing that, but I'll give it a shot:

  • [B]clrscr();[/B] is unportable rubbish :)
  • gets(nm); , use cin for that!
  • Use of old-style headers:
    #include<fstream.h>
    #include<conio.h>
    #include<stdio.h>
    #include<string.h>
    #include<stdlib.h>

    conio is not part of standard C++ ...
    For I/O, use the iostream classes !

  • As I see so much void functions in your code, your main function will be void as well, in that case: make it int main()
  • Indent your code, it's a real crap now!
tux4life 2,072 Postaholic

Better try to read this forum rules before 6th of June:
http://www.daniweb.com/forums/announcement8-2.html

Yes, and read this as well :)
And when you think you know the forum rules, you can come back, deal?

tux4life 2,072 Postaholic

>have recently upgraded from Allegro 4.2 to Allegro 5
Actually you aren't using Allegro 5 yet, you're using a Work-In-Progress (WIP) release for the future Allegro 5.0 branch :)
So I don't know whether this Allegro is already finished yet, I personally think it isn't.

>In Al 4.2 I could just use an "os_type" variable, but no such variable exists in Al 5.
And how do you know that?
What errors is your compiler giving? Sure that you linked the library correctly with your application?

Note: It might be a better idea to post your future allegro questions on an allegro forum, as there are probably more people with Allegro knowledge.

tux4life 2,072 Postaholic

>If You Want Something To Do
Yes, I want to give you some links you should consider looking at before you start posting on this forum:

Read this before posting
Forum announcement I
Forum announcement II

Come back when you've read them :)

(It will take you a couple of minutes to read them, but it will save us lots of time we can use to help other people)

tux4life 2,072 Postaholic

Read all the names into a vector and use the sort algorithm to sort them alphabetically :)
You could also sort it by using the strcmp function if vectors aren't allowed.

If both of them aren't allowed then you'll have to implement a sorting function first
(you could take a look at this code snippet in that case, it does exactly the same as the strcmp function) ...

tux4life 2,072 Postaholic

Apples are red,
The sky is blue,
If he posted using code tags I was happier too.

:P

tux4life 2,072 Postaholic

A password program which is only accepting passwords which consist out of one character is not a bad coding practice, but it's a bad security practice :)

tux4life 2,072 Postaholic

First some remarks on the OP's code:
Use new-style headers if possible, so:

#include <iostream.h>
#include <stdlib.h>
#include <fstream.h>

would become

#include <iostream>
#include <[B]c[/B]stdlib>
#include <fstream>

Avoid the use of system("pause"); (look in my signature, for a replacement and the reason on why to avoid it)

:)

iamthwee commented: good advice +21
tux4life 2,072 Postaholic

what is SDL ?

SDL is a cross-platform multimedia library for C++.
Take a look here: http://www.libsdl.org/ :)

tux4life 2,072 Postaholic

Took from the php manual:

Note: When sending mail, the mail must contain a From header. This can be set with the additional_headers parameter, or a default can be set in php.ini.
Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. The From header sets also Return-Path under Windows.

Conclusion: You haven't configured it in your php.ini file :)

tux4life 2,072 Postaholic

>Can someone help me to make a program in java
Yes we can help you, please post the code you have so far (read this) and tell us where exactly you're having problems with.

tux4life 2,072 Postaholic

Could you please post using code tags?
Is it that difficult? Just click the # button (and past your code in between the tags).
Read also this and this :)

tux4life 2,072 Postaholic

>The compiler say "Link error" and ...
And what?
Could you please post the whole error message (plus code), and what's Array ?

tux4life 2,072 Postaholic

>definitely it's the crappiest program language...
On what arguments do you base this?

C++ is a more advanced language and it will allow some things other programming languages won't ever let you do, if you write a program in C++, and you are a good programmer, this will reflect in your work, but when you're a bad programmer, this will also reflect in your work :P

So, IMO this code is just crap ! (and now you read the above info again :P)

>I have no f* idea what they are they just showed them and want me to do it..
I've also no f* idea of your problem because you haven't posted the whole code as already mentioned by Ancient Dragon :)

tux4life 2,072 Postaholic

Replace char password; with char password[31]; And change cin >> password; to cin.getline(password, 30); If you declare password like char password then you tell your compiler to reserve memory for one character only, but we want a set of characters (a string, an array of characters), so we write something like: char password[31]; (this string will be capable of holding 30 characters (plus the null-terminator))

BTW, Read my remark on the use of system("pause"); (it's in my signature)

tux4life 2,072 Postaholic

1)
int arrA[];
int *ptrToarrA = arrA;


2)
int arrB[];
int *ptrToarrB = arrB;
Now it is correct. When you enter a value in the array it store in *ptrToarrB and if you want to enter more values in the array you run a for or while loop for this purpose.
Any problem tell me.

This is wrong, you don't assign memory for the array, this doesn't even compile, my compiler gives the following error:

t.cpp:7: error: storage size of `arrA' isn't known

To the OP (regarding post #1): Well, both are wrong for the same reason: Before you assign a value to a location in computer's memory, your pointer has to point to some memory first, otherwise you're overwriting random memory :)

tux4life 2,072 Postaholic

What about using string patterns ?

tux4life 2,072 Postaholic

i want to validate the String entered wether it is a valid standard equation of conics
the standard equation is:
ax^2+by^2+2hxy+2gx+2fy+c=0
some variables can be missed in input string but it should be of "degree 2" equation

Do you mean a quadratic equation like this: ax^2 + bx + c ?

By the way: May the terms be placed in another order?

Edit:: Sorry: I see that it's not what I thought, it's a conics equation (:P) ...

tux4life 2,072 Postaholic

>We take a look at them.
What do you mean: we ?

:P

tux4life 2,072 Postaholic

She/He still doesn't want to believe that I am a human :'(

User: Hi, my name is tux4life.
Cleverbot: What a strange name!
User: Yeah, I know, it's my nickname.
Cleverbot: Do you always say yes?
User: No.
Cleverbot: What do you do on your days off?
User: Nothing special, being active on daniweb (a forum) and programming.
Cleverbot: So if you are a man where do you live?
User: In Belgium and where do you live?
Cleverbot: In the United States. What state?
User: In Belgium we don't work with states.
Cleverbot: Nottingham. How old are you?
User: Can I also ask a question?
Cleverbot: That's incredibly funny in afghanistan.
User: Lol, no this isn't right.
Cleverbot: I'm looking for a bot who is also a professor.
User: Ah, are you married?
Cleverbot: Nope but I am in a relationship.
User: With who? What's her name?
Cleverbot: Jenna.
User: Strange name.
Cleverbot: You are a girl o a boy?
User: The second one, but did someone just talk with you about runescape?
Cleverbot: Thats true, but what about the first?
User: Boy.
Cleverbot: I'm a girl.
User: Do you know in what programming language you're written?
Cleverbot: Yes english.
User: That's not possible!
Cleverbot: Yes, you are a computer.
User: We're talking about you, by the way: I'm a …

tux4life 2,072 Postaholic

>What is the different between exit and break?

The exit command is used to exit the whole program and return a value to the operating system.
The break command is used to jump out a loop or to prevent running the instructions in the next case, if we're talking about the switch statement :)

Consider also the following links:

tux4life 2,072 Postaholic

>In short if I remove the null terminator I get the same garbled output, Is there something about null terminators and LPCWSTRs I should know?

Yes, when writing a character string to the screen, everything is written to the screen until the NULL-terminator has been encountered, however if there isn't one, then the memory after the character string will be displayed as well, which in most cases gives you that garbled output :)

tux4life 2,072 Postaholic

You should use break; instead of that exit command :)

tux4life 2,072 Postaholic

Then try:

cin.get();
cin.get();

:P

tux4life 2,072 Postaholic

Take a look at this code and see what I've changed:

#include <iostream>

using namespace std;

void printTriangle(int, [B]char[/B]);
void drawBar(int);
void drawBar(int, [B]char[/B]);


int main()
{

int base(0);
char sign(' ');
cout << "This program draws a Triangle" << endl;

cout << "\nEnter the triangle base size: ";
cin >> base;

cout << "\nEnter a character: ";
cin >> sign;

printTriangle(base, [B]sign[/B]);

[B]cin.get();[/B] // replace system("pause");
}

void printTriangle(int bs, [B]char sign[/B])
{
	for(int i = 0; i <= bs; i++)
	{
	drawBar(i);
	cout << endl; 
	}

	for(int i = 0; i <= bs; i++)
	{
	drawBar(i,[B]sign[/B]);
	cout << endl; 
	} 

	cout << endl;
}
void drawBar(int b)
{
	for(int i = 0; i < b; i++)
	{
	cout << "*";
	}
}

void drawBar(int b, [B]char ch[/B])
{
	for(int i = 0; i < b; i++)
	{
	cout << ch;
	}
}

:P

tux4life 2,072 Postaholic

Yes I read it, but I just want to figure out why I am getting symbols for the second triangle instead of the user output... Are you saying that is why?
I am new to c++, so pardon my noobiness... =)

Actually you could treat a char variable as a small integer, each character has it's own 'integer code', which is more commonly referred to as ASCII code, what you do is the following: you just pass the loop's index as an ASCII code which will be implicitly converted by the compiler to it's equivalent character, and that will give the unexpected output :)

tux4life 2,072 Postaholic

Dave did already mention what the problem is with your code:

You'll have to let your function know about the character you want to print instead of doing this:

drawBar(i,i);

You should read more carefully!

tux4life 2,072 Postaholic

Did you read my remark on the use of system("pause"); in my signature :P ??

tux4life 2,072 Postaholic

Well, first you should begin with the most important thing: drawing a triangle which only consists out of '*', don't care about the '#' or '^' yet, you can quickly adapt it later on, to accept other characters as well :)

To give you a little start:
(in the next examples I'll call the number the user enters the number of iterations)
If the user enters for example 3 then your triangle will look like:

[B]/* number of iterations is 3 */[/B]
*          // iteration 1 ( loop indexes )
**          // iteration 2
***          // iteration 3

And if the user enters 4 then your triangle would look like:

[B]/* number of iterations is 4 */[/B]
*          // iteration 1 ( loop indexes )
**          // iteration 2
***          // iteration 3
****          // iteration 4

So what can you derive from that?
You'll have to run two loops: one which is simply looping <number_of_iterations> times and one which each time prints a certain number of asterisks on the screen (and that number is equal to the current loop index)

amrith92 commented: Nice, subtly explained post! +1
tux4life 2,072 Postaholic

It's probably better to make the following variables private in your struct (as you have already input/output functions):

int ID;
int salary;
int division_code;
int job_code;

Every data member of a struct is made public by default, however you could use the data access specifiers to encapsulate some data members, like this:

struct employee {
[B]// your other stuff goes here[/B]
[B]// please note that you could use the public access specifier here, but it's[/B]
[B]// not really required, because a struct's data members are public by default,[/B]
[B]// unless specified else[/B]
[B]private:[/B]
  int ID;
  int salary;
  int division_code;
  int job_code;
};

:P

tux4life 2,072 Postaholic

My ISP places a limit on the size of an upload. Could yours be doing that?

Yes, but there's no such thing as: a file may be only xxxxMB or so.
There's something like a counter for all the traffic (upload and download), in other words: I'm allowed to upload files from any size unless I have reached the upper bound of my counter :)
(The counter's limit is 25GB and will be reset to zero every month)

tux4life 2,072 Postaholic

I have no clue what you mean...
Could you demonstrate the expected output using an example?

tux4life 2,072 Postaholic

Why do you use old-style header for the math library? #include <math.h> in C++, the new-style headers are preferred: #include <cmath> :P

tux4life 2,072 Postaholic

Create a vector of type wchar_t and store the values in it :)
Remember that you'll have to use wcin and wcout if you want to do I/O

tux4life 2,072 Postaholic

>I am looking for a script to do that for me.....
Take a look at this page.
Though you'll have to adapt it a bit, but it implements all the basic stuff already :)

Or better: http://www.java2s.com/Code/C/File/Copyonefiletoanother.htm

tux4life 2,072 Postaholic

>I didn't think non heap variables could be said to be allocated because they are allocated by the OS at startuptime
Not necessarily, they're automatically allocated when the code block in which they're defined is entered/executed :)

BTW, what would be the advantage of wrapping all the variables of your program in one class? (what advantages do you see in it?) I don't see any advantage in it, I find it sluggish and a very bad coding practice as well ...

Remember: It's not because you can do something that you'll have to do it as well :P

tux4life 2,072 Postaholic

[B]bob = *Astring;[/B] won't copy Astring in bob, for that purpose you'll have to use the following code instead: strcpy(bob, Astring); :P

>However there is no real *right* way of doing it
But there are good and bad ways to do it :)

tux4life 2,072 Postaholic

>I am looking for a script to do that for me.....
Take a look at this page.
Though you'll have to adapt it a bit, but it implements all the basic stuff already :)