Okay, problem solved. Used matches() instead of equals() :) Thanks again
Okay, problem solved. Used matches() instead of equals() :) Thanks again
see here:http://www.vogella.de/articles/JavaR...s/article.html and here:http://mindprod.com/jgloss/regex.html
but why not use a simple if statement to separate the input into what you want?
Hey, thanks. Co incidently , I bumped into these same tutorials just now.Was just checking them out. :) :)
but why not use a simple if statement to separate the input into what you want?
These are just some enhancements that i need to add in a previous code. I am bound to use regex,so not going for any other option at this moment . Anyway, thanks :)
printf("\nPlease select a starting position for a figure for instance E2 in upper case\n");
scanf("%1s%d",&c,&y);
Might be a problem here. Try printing values of c and y and see if you are getting proper values. I suppose it is because you are giving your input as E2 rather than E 2. Also use %c for c
I want to create a regular expression that matches with the string
"B. Hello" or "C. Hello" and so on..
I tried number of things and finally came up with this
String REGEX = "[A-Za-z]"+Pattern.quote(".")+" Hello";
but still no luck.. I tries using '\s' for space but still not working. Can anybody help me out with this. Ultimately , i need to do something like this
if("B. Hello".equals(REGEX))
System.out.println("Hello ,B ");
Thank you
.if the above condition is false i dont want my code to go further and calculate the input.How and i able to do this.Presently everytime i enter an invalid number ,it still processes the output but also come up with the statement"invalid number".
If you want to straight away exit your program you will have to use exit() inside if statement. If you are in a loop and simply want to get out of the loop then you will have to use break as mentioned by adil bashir
if(a < 1 || b < 1 || c < 1 || d || 1)
{
System.out.print("Invalid Input");
break;
}
You need to decide whether you want to use '&&' or '||' depending on what condition you wan to check. If you are looking for any one of a,b,c,d to be < 1 then above code using or condition is fine . If your condition is true when all a,b,c,d < 1 , then you will have to use and (&&) instead
Who can do it in C++??
Maybe ,you can
Hi!This Is My Code after formatting and compiling- still need some help in main function.
What help do you exactly need ? Is your code working now or are there still any compiler errors. If so, post them too
Whenever a function is called , it is pushed on to a stack (called as a frame). Whenever a function returns, it's frame is popped out. This is how flow is maintained. Now , suppose you call a function inside main() , and that function calls exit() , which is also a function, exit is responsible for clearing (popping) stack frames for all functions below it in stack (including main()), and thus process is killed.
I do not have much idea about how it is actually implemented though. I have explained it to you in a very abstracted way, there are many more details involved
You have understood the concept , i guess . But the way u have put it is a little ...ummm....
The pointer variable '*p' does get reassigned to the value of the pointer variable '*q' (98). So essentially both pointer variables (*p, *q) hold the value 98.
This is OK..
Now,
Because the address of the variable 'x' and 'y' are held in pointer variables '*p' and '*q' respectively, when the system calls to output 'x' it looks for the location of 'x' (&x), which is stored in '*p' and then outputs the value of where that location is: value of '*p' (98). And the same with 'y'. Correct?
I would put it something like this,
Whenever you say *p = some_value , what is done here is set some_value to the value of location pointed by p
Thus , when you do *p = 35; , it is same as x = 35
when you do *p = *q , you are doing nothing but x = y
Just print counter inside while loop of your first code. You will get
2
4
6 etc
Rest of the code seems fine
while(NotPrime=FALSE){
If will do here since you just have to check the condition once. Also NotPrime=FALSE assigns NotPrime ,the value false. For equality checking , use ==
Logically, if a number is not prime (i.e. composite) set your variable NotPrime to true not to false, here :
if (number % x == 0)
{
bool NotPrime=FALSE; // It must be set to true and again don't re declare NotPrime here
cout << " This is a Composite" << endl;
}
if (number % x == 0)
{
bool NotPrime=FALSE;
cout << " This is a Composite" << endl;
}
You don't need to re declare NotPrime. This will create a new variable in a new scope and destroy it as you leave if block. Basically, you don't need to re assign it to false also. Initializing it to false eventually means that you are assuming that number is composite , so you don't need to do that again
Didn't quite get your question... What EXACTLY are you looking for ?
int *p = &x;
You can break this statement as
int *p; // Define a pointer to an integer (p is a variable that
// is capable of holding address of an integer variable
p = &x; // & can be said to be 'address of' operator. hence
// assign to p address of variable x
Now whenever you say, *p , it means de-referencing p. That means , *p gives you value of variable at address contained in p i.e. nothing but value of x
But let's be realistic. Despite the flexibility of the CLI, how often do you see common production use of anything other than the two heavy hitters: C# and VB.NET?
Exactly. Totally agree with you. I am not saying that .NET is better than Java just because it supports 56 languages. In fact, what I want to convey is that it doesn't really make much of a difference.
fork returns two values ,0 for child process, and pid of child for parent process. Hence , your if is always true and it runs for parent. If you want some code to run for child you will have to check
if(fork() == 0){
// your code
}
Also , just to add a small point, architecture of .NET is very much similar (rather picked up ;) to Java's architecture. The only difference being in the number of compilers. Java compiles only .java source files , where as in .NET , AFAIK, you can code in around 56 different languages
Quote ...
which is the best programming language between java and .net.
.NET isn't a language, it's a framework. You probably mean Java and C# as they're very similar in terms of syntax, but it's still impossible to compare languages without a very specific context and well defined points of comparison. Just asking which is better will get you nothing but subjective answers.
Quote ...
JAVA would be slower than .NET since there is a middle man (JRE). In other hand, JAVA comes for FREE..
Both points are incorrect. Java supports JIT compilation just like .NET languages, and the slowness argument stopped being valid around the turn of the millennium when Java started to really mature. Also note that .NET's CLR roughly corresponds to the JRE in terms of being a "middle man".
Like Java, .NET as a development platform including a compiler can be downloaded for free, and you can even get Visual Studio, one of the better IDEs on the market, in one of the free Express versions.
Completely agree with all that you said. Infact, I was about to say the same.
Mark it solved if it is working
Compile time errors are syntactic errors, they are notified at compile time i.e. before you run your program . Exceptions are run time errors.
Compiler does not recognize them. You know you have encountered an exception only once you execute a program.
stein worked a bit on his own, and in his day, most people thought of him as bit of a goof. Jobs' clothing is a very different matter than having piercings and such (not too mention it kind of helps when you're the boss instead of an employee ) and as for Ritchie's beard: did he already have that beard when he started working? it's also good to know that when Ritchie was first hired, the entire HR business was a lot different: you have a degree, you are good at developing? hired!
it didn't really matter how they looked, since it were mostly the ones referred to as "geek" or "nerd" who had the skills to get the job done. nowadays, however, you'll find yourself in another situation: the IT dept. is no longer a place hidden from the world, where a few lonely IT-guys take care of a mainframe the size of a small house.
personally, I don't think it matters either, but I'm well aware a lot of recruiters dó think it matters. In my personal experiences, yes, there are firms where you can arrive in shorts on a hot summers day, but there are also companies that say: you're not wearing a costume and tie to your interview/workday? good-bye.
so yeah, there are companies that don't mind, especially if you have the skills they need, but without actual experience, that might still be hard to prove
May be what you are saying is right. IT IS …
I agree with happygeek in this case. Yes, its true most of the companies will consider your looks while recruiting you. But personally, I believe that looks really don't matter. May be people will have misconceptions about you at the beginning, but if you have true talent, it will be proved.
Not to forget Sir Albert Einstein's hair, Dennis Ritchie's long beard, or Steve Jobs' simple blue jeans black T. They never cared about all these things , because they were busy "working", and eventually people started caring about their work too rather than their looks.
These are all personal opinions, I just wanted to share mine. :) :)
f you want it to be linked to products, you might as well tell us if you already have a name for a product (or at least a concept of what it's going to do).
just a small tip, though: don't try 'Microsoft' or 'Google'. I hear they're taken
LOL :D :D
Anyways,as I said right now we will start with services only. We are looking out for a name that is more general. Not related to any product as of now. So anything random you find interesting and catchy, and that can serve as a good but professional company name , let me know :)
Right now service. But I am looking for a more generic name (if in future, we think of products ;) :P )
We are a group of 3. So I came up with something like
Trinity Technologies :D
Looking forward for some great suggestions... :)
if(a!=52||a!=55) //this condition is not working?
Since you want to count those which are not 4 or which are not 7,
this should work according to me...
if(a[i]!=52 && a[i]!=55)
Use AND condition
try {
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
} catch (Exception e) {
System.out.println("Driver is missing");
}
Write this code before you create a connection. That is , your code will first have this statement
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
then
con = DriverManager.getConnection(host, uname, pass);
Hey guys,
Could you please suggest some nice/catchy names for a start up software company. Looking for a name that has good meaning . I went through a few names , some Greek Gods names, even names of few chemical elements that I found have good meaning. Your suggestions are most welcome.
Thank You :) :)
Ok..the thing is..when you want to display the list ,you have to traverse the list from the beginning(in a loop), and display each element until end of list is reached.
What you are doing will only display current data that you have entered.
Basically, linked list are dynamic in nature. Hence , your code
for(int i=0; i<3; i++)
is not suitable for linked list ,since it restricts its size to 3.
Anyway, because you are still new at it. Let us solve your first problem here. Let us for now assume that linked list can have maximum 3 elements and continue with your code for the time being.
Now , you need a loop inside your loop, that traverses the list, and cout all elements one by one.
p -> next = NULL;
With this you are not creating a linkedlist at all. In linked list , an element's next points to some other element and so on and thus a list is formed. Here since you are assigning null, your element points to nothing, its an individual struct variable, not a part of the linked list.
I would suggest read some theory on linked list first and then start coding. Once you understand the concept ,it will be much easier
Ohh..no no. Not this line. I asked you to comment the other two lines. Just check that
t HelloWorld.main(HelloWorld.java:28)
Which is your line number in the code.
I guess it is this :
ConfigurationManager cm = new ConfigurationManager(new URL("http:\\www.google.com"));
You need to this correction JamesCherill said :
"http:\\www.google.com"
In Java \ is a special character, used to start escape sequences in string literals. "\\" in a string literal is only a single \ character in the String itself.
Use "http:\\\\www.google.com"
so what is the error means? sorry i have just learn these things.
again thanks for you help.
Hey thats ok.. Even i am learning. Everyone here is to learn. Anyways,
java.lang.NullPointerException
Null pointer exception means you are calling a function on an object that is null.
new studentMain().setVisible(true);
This might be the problem .Even I am not sure but try
studentMain stud= new studentMain();
stud.setVisible(true);
or simply
(new studentMain()).setVisible(true);
I am assuming there are no problems with your studentMain class.
or if this doesn't work then it means
rs = cmd.executeQuery(sql);
here cmd is null.
But I think, it must be the first one only.
Ok.. so you need to first post some code you have done on your own..
Why are you expecting it to be 4 bytes? 3 characters, 1 byte each , total 3 bytes.
The standard uses a simpler description:
Okay.. got it to some extent. I will check the description given in the standard.
Thank you.
at comstar.studentMain.doConnect(studentMain.java:52)
at comstar.studentMain.<init>(studentMain.java:94)
at comstar.studentMain$1.run(studentMain.java:390)
Which is line number 52,94 and 390 ?
You will get a pretty decent idea from this post
http://www.daniweb.com/software-development/computer-science/threads/19933
I am reading Kernighan and Ritchie, and honestly, I am not able to understand anything in the following sentence I encountered while reading:
Any integer is converted to a given unsigned type by finding the smallest non-negative value that is congruent to that integer,
modulo one more than the largest value that can be represented in the unsigned type.
Could anyone please clarify what congruent means here and try explaining to me what does this sentence exactly convey(if possible , with an example).
Thank you
P.S. I am referring to Appendix A Section A6.2 : Integral Conversions
What error are you getting?
for(int i = row; row > 0; row--)
Why row>0 and row--. Should it not but i>0 and i-- ?
Why have you put the code inside for loop in comments? Your function check_column is returning true in any case.
And ident your code and repost it using code tag
Try displaying the result of the query on console using System.out.println() . And see if it prints something, it means your query is working fine,problem is while displaying it in text boxes. Check whether wherever you have used getString() are actually strings/text in your table.
for (a = 0;j< size-1; j++)
What is 'a' ? I think it should be j ?
void swap (int *x,int *y);
You have written a function prototype inside another function. That is wrong
void dataSort (float sLengthArray[],float rSlopeArray[],float speedArray[], float size)
I find only three arrays here,not 4
Could you explain your problem and your code more clearly...
What exactly is the output you want to achieve?
Can you give us an idea of what you want to do next or are you asking for suggestions for what to do next?
As zeroliken said, now let us know what exactly you want..
I think he just didn't notice it
possibly yes... :)
DatabaseMetaData dbmd = con.getMetaData();
rs = dbmd.getTables(null, "APP", "STUDENT", null);
I am not sure why have you used these lines. Just try commenting them and run your code.
(325) : error C2181: illegal else without matching if
Now this is how formatting would help you. You can clearly see one else is misplaced
int rook_moove(int x1,int x2,int y1, int y2)
{
int dx,dy;
int i,j;
dx=abs(x2-x1);
dy=abs(y2-y1);
if(((dx!=0)&&(dy=0))||((dy!=0)&&(dx=0)))
{
printf("Cannot moove- the m oove is illegall!\n");
return 0;
}
else
{
for(i=x1+1;i<x2;i++)
{
if(check_if_empty(i,y2))
{
update_board(x1,y1,x2,y2);
print_board();
return 1;
}
}
}
else
{
for(j=y1+1;j<y2;j++)
{
if(check_if_empty(x1,j))
{
update_board(x1,y1,x2,y2);
print_board();
return 1;
}
}
}
}
More specifically , this is the else
else
{
for(j=y1+1;j<y2;j++)
{
error C2143: syntax error : missing ';' before 'return'
There must be a semicolon on line 380 after print_board()
syntax error : missing ')' before '!'
There is nothing like !< . Use > (greater than) or >= whichever is appropriate
By formatting , I mean something like this
if(c=='Q')
{
printf("BYE BYE\n");
}
else if((c!='A')||(c!='B')||(c!='C')||(c!='D')||(c!='E')||(c!='F')||(c!='G')||(c!='H'))
{
printf("Sorry wrong column selection. Re enter.\n");
return -1 ;
}
else
x=c-65;//A will be converted to 0, B to 1, etc...
You already have done most of the code. You only need to make small changes to make it generic.
Take input from user in ,say , n. Your 9 (number of rows will be replaced by 2*n - 1).
Your j will now start from n (since it is the number of stars you want to print on the first line) and again instead of checking counter against 5 you will check it against n. Give it a try. Post the code back if there is a problem. :)
Also another problem I notice in your code is, even though counter > 5 , inner for loop of j will still be executed. But you don't want that to happen. You only want for loop with index o to run now. So , you need to use else statement here.
You can do,
if(counter < 5)
{
//your first inner for loop with j index
}
else
{
//your second inner for loop with index o
}
And format your code like this, so that it becomes easy for you to understand and debug
#include <iostream>
#include <conio.h>
using namespace std;
int counter=1;
int m=1;
int n,j,o;
int main()
{
for (n=9;n>=1;n--)
{
for (j=5;j>=counter;j--)
{
cout<<"*";
}
if(counter>5)
{
for (o=0;o<=m;o++)
{
cout<<"*";
}
m++;
}
counter++;
cout<<endl;
}
getch();
}
The number of lines/rows in your output is 2*n - 1 where n is the number you enter. For ex. if you enter 5 , you will have 9 rows, if you enter 3, you will have 5 rows.
Hence, your outer for loop should have a condition that is related to the number of lines that will be printed. Your inner for loop will decide how many stars to print depending on which line it is (that is nothing but index of your outer for loop.)
Also , your entire code of setup_board() can be re written much efficiently using a for loop.
So many more... please do the formatting