15,907,910 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by amin.j (Top 35 by date)
amin.j
30-Oct-15 14:02pm
View
I used this code but it has error in 4th line:
# y= 0.4*x+1
li.s $f0, 0.4
mul.s $f2, $f0, $f1
floor.w.f $f3, $f2
amin.j
30-Oct-15 10:25am
View
As I know:
mul.d $destination, $source, $source
the third one is the second float pint for multiplying. But, my case is different, I want to multiply one integer in $t1 with a float in $f0; how can I do that?
amin.j
30-Oct-15 7:33am
View
I have an integer value in register $t1 and I want to multiply it with 0.4 but it has error in the second line:
li.s $f0, 0.4
mul.d $f1, $f0, $t1
mfhi $a2
mflo $v0
# print the result
li $v0, 2 # load appropriate system call code into reg $v0
la $a0, 0($v0) # load address of string to be printed on $a0
syscal
amin.j
18-Oct-15 3:44am
View
This code is working:
if(*(static_cast<const int*="">(elem1)) == *(static_cast<const int*="">(elem2)))
amin.j
18-Oct-15 3:02am
View
How can do the same for Class data type, here DayOfear:
bool equals_class(const void* elem1, const void* elem2){
`if ((*(DayOfYear*)elem1).month == (*(DayOfYear*)elem2).month && (*(DayOfYear*)elem1).day == (*(DayOfYear*)elem2).day){`
I use this one:
`if ((*(static_cast<dayofyear*>(elem1)).month == (*(static_cast<dayofyear*>(elem2)).monthh &&
(*(static_cast<dayofyear*>(elem1)).day == (*(static_cast<dayofyear*>(elem2)).day){`
but it makes error:
static_cast from type 'const void*' to type 'DayOfYear*' casts away qualifiers|
amin.j
18-Oct-15 2:49am
View
Dear Andreas, thanks a lot it works. However, is it possible to explain it more what is the error is about and what the solution does!
amin.j
18-Oct-15 0:54am
View
I did this code for substituting the typecasting in C++ instead of the above code in C but it doesn't work. There should be a dereferencing after typy casting.
bool equals_int(const void* elem1, const void* elem2){
if (*(static_cast<int*>(elem1)) == *(static_cast<int*>(elem2))){
....
amin.j
5-Aug-15 13:55pm
View
Dear @Philippe, what are your suggestions for me to write real C++ code? I mean what is the fastest and straightforward way to learn that? Is there any tutorial or valuable book or whatever else?
amin.j
5-Aug-15 13:16pm
View
Dear Richard, Many thanks for your suggestions. I did that and it is solved. i have a question: Do you know some tutorial or sth that really teaches great features of C++? I mean to read sth useful in a short time.
amin.j
5-Aug-15 10:13am
View
-1's are going to the first of the array, not at the last..
-1-1-1345
amin.j
5-Aug-15 9:40am
View
Deleted
I mean this code that you send, it came to my email but it is not showing in this page! "Actually you don't even need to fill with -1 a vector, however just to show it:.... "
amin.j
5-Aug-15 9:33am
View
Deleted
dear CPallini, thanks. I cannot see your previous codes about pushback in this page, do you delete it? And you know, I need to use this -1, this has a reason I put it there.
amin.j
5-Aug-15 9:07am
View
Can you explain more? If you can give me an example of in which part of the code I use vector, that would be great. If you have suggestions for me to go from C to C++ and correct my way of programming that would be your kindness. Thank you so much for your care.
amin.j
5-Aug-15 8:39am
View
I have two arrays: equiDisStr1 and equiDisStr2
I want to compare these two arrays and if the size of them are not equal, make it equal by defining new array with the maximum size of two arrays; in fact, I fill the remainder of new array by -1 (which is a flag for me).
--- for example
equiDisStr1 : 2345
equiDisStr2: 3457604
So: size(equiDisStr1) < size(equiDisStr2) ---->
Output: updDisStr == -1-1-12345
equiDisStr2 == 3457604
now, size of both are 7. And based on the other parts of the program, I need to do this way.
amin.j
5-Aug-15 8:10am
View
Dear @CPallini, I did what you said, program is running now after debugging but I got an strange output something like that: 4765800241! Do you think I'm doing wrong?
int addResult, updLen;
int diffLen = abs(lenStr1 - lenStr2);
if (lenStr1 > lenStr2){
updLen = lenStr1;
int updDisStr2[updLen];
lenEqualize(updDisStr2, equiDisStr2, diffLen, updLen);
cout << updDisStr2[0]; // here is the point
}
else if (lenStr1 < lenStr2){
updLen = lenStr2;
int updDisStr1[updLen];
lenEqualize(updDisStr1, equiDisStr1, diffLen, updLen);
cout << updDisStr1[0];
}
else if (lenStr1 == lenStr2){
updLen = lenStr1;
}
void lenEqualize(int* updDisStr, int* shortLenStr, int diffLen, int updLen){
for (int i = 0; i < updLen; i++){
if (i < diffLen-1){
updDisStr[i] = -1;
}
else {
updDisStr[i] = shortLenStr[i-diffLen];
}
}
}
amin.j
5-Aug-15 7:59am
View
I read book and know basics of that. But when it comes to practical, it is a different story. First, I didn't write the code in this way which I defined array outside function, but some people said doing this way. Now, what is your suggestion: there is two ways, first I define an array and give it to the function to change, second define the array inside the function and return it.
amin.j
5-Aug-15 7:45am
View
Deleted
Dear Richard, this is part of my code after I changed some lines based on the suggestions.
------ main part:
int addResult, updLen;
int diffLen = abs(lenStr1 - lenStr2);
if (lenStr1 > lenStr2){
updLen = lenStr1;
int *updStr = lenEqualize(equiDisStr2, diffLen, updLen); // error is here
}
else if (lenStr1 < lenStr2){
updLen = lenStr2;
int *updStr = lenEqualize(equiDisStr1, diffLen, updLen);
}
else if (lenStr1 == lenStr2){
updLen = lenStr1;
}
------ function:
int *lenEqualize(int shortLenStr, int diffLen, int updLen){
int updDisStr[updLen];
for (int i = 0; i < updLen; i++){
if (i < diffLen-1){
updDisStr[i] = -1;
}
else {
updDisStr[i] = equiDisStr1[i-diffLen];
}
return updDisStr;
}
------ function declaration:
int *lenEqualize(int shortLenStr, int diffLen, int updLen);
amin.j
5-Aug-15 5:34am
View
You mean I use vector instead of pointer?
amin.j
5-Aug-15 5:29am
View
This is part of my code that gives error: when I changed that to
cout << updDisStr2[0];
now it say that updDisStr2 is not declared, but I declared it in the if. I am really confused?
if (lenStr1 > lenStr2){
updLen = lenStr1;
int updDisStr2[updLen];
lenEqualize(updDisStr2, equiDisStr2, diffLen, updLen);
}
else if (lenStr1 < lenStr2){
updLen = lenStr2;
int updDisStr1[updLen];
lenEqualize(updDisStr1, equiDisStr1, diffLen, updLen);
}
amin.j
5-Aug-15 5:12am
View
I corrected the code by your comments, the error is solved. Now, how can I reach the element of updDisStr2? I used this for the first element of this array:
cout << *updDisStr2[0] ;
but it sends error.
amin.j
5-Aug-15 4:52am
View
You got that. It needs size. But the size is not specific at the start of program. Is it possible to have a vector with call by reference?
amin.j
5-Aug-15 4:49am
View
I want to change the values of that array in the function. And don't return sth.
amin.j
5-Aug-15 4:44am
View
I removed but it is not solved.
amin.j
4-Aug-15 10:45am
View
Thanks dear nv3 for your valuable comments. Nice to meet you here today.
amin.j
4-Aug-15 8:16am
View
Yes, exactly. How it is possible to the outer for loop to write in this way?
for(auto c: s){
}
amin.j
4-Aug-15 8:07am
View
Thanks. I got that but not completely. If you can give comments about that, it would be great.
amin.j
4-Aug-15 7:59am
View
Thanks. This kind of for loop, with auto keyword, is the only way to reach elements? I mean isn't there the old fashioned for loop style: for example,
for(int i = 0; i < max; i++)
amin.j
4-Aug-15 7:45am
View
Dear nv3, many thanks. I want to use the elements of vectors in set s; for example if :
s:
01
02
...
I want to reach the 0, 1, 2, ... in each vector. How can I do that? Old-fashioned for loop I mean simply!
amin.j
4-Aug-15 7:02am
View
Dear nv3, I have another problem. I don't understand the nested for-loop at the end of program (auto i: c); if it is possible to write it more simply? In fact, I want to use the elements of the set s and how I can do this?
for(auto c: s){
for (auto i: c)
cout << i << " ";
cout << endl;
}
amin.j
4-Aug-15 4:09am
View
Dear nv3 many thanks for your valuable comments in your solution.
amin.j
4-Aug-15 3:04am
View
Thanks. But I mean how set is filled; in fact, if it is possible, please give me the explanation of the first iteration of the do-while loop when i = 0; what happens in the loop and what is the output?
amin.j
4-Aug-15 3:04am
View
Thanks. But I mean how set is filled; in fac, if it is possible, please give me the explanation of the first itheration of the do-while loop when i = 0; what happens in the loop and what is the output?
amin.j
4-Aug-15 1:50am
View
Thanks dear barneyman, but I want to know the s.insert(v) procedure? What happens there? If you can give me the explanation of one iteration of the do-while loop, that would be great.
amin.j
4-Aug-15 0:56am
View
I know but how it works? Please give me a kind of example by this program.
amin.j
4-Aug-15 0:47am
View
Dear Sergey, I don't know how it works and what happens when program reaches this line? If you can give me an explanation by example, that would be great.
Show More