It is rude to bump old threads like this. Thread Closed.
WolfPack 491 Posting Virtuoso Team Colleague
It is rude to bump old threads like this. Thread Closed.
I gather that my predecessor
1. Was really good with computers and
2. Used a pirated version of Visual C++.
Oh, well. First time I have heard something like this.
As for the second part, I should have been more specific. It's several 1,000,000-element arrays of pointers to 27 element arrays.
Try using the debugger and see whether this variable jumping is random or not. Maybe you can find a pattern, and then you should be able to figure out the cause. Also check the maximum value that can be stored for this variable type. If it is less than 1,000,000 then that is the problem. A 32 bit integer should be able to hold 1,000,000 but make sure for your environment.
wrote it using Microsoft Visual C++ on a Linux operating system,
Is this actually possible? MSVC runs on Linux? :eek:
but one variable (the one monitered to determine when to stop iterating through the simulation) is jumping all over the place, instead of the expected steady decrease.The program makes use of some very large arrays (some of which contain 27 million elements)
27 million = 27000000
What is the data type used for this variable? Maybe it can't hold 27000000. Most probably it starts back from 0 after being assigned it's maximum possible value.
Hello,
I couldnot understand the working of strtok().....does it parse the string in <>.....then how come it displays the names of countries etc. which are not in <>......or it parses only 1 delimiter < at a time......but then why do we write strok(s1,"<>"); .....i followed the link you gave me but i couln ot understand its working so could you throw some light on this topic.......
Thanks
I suggest you try parsing just one line instead of the whole file, and see what are the contents pointed by pos, and the original array step by step by adding some printf statements. Then try to see how that agrees with the explaination given by that site. You will have a better chance of understanding the code that way.
Okay Dani. It seems that my work computer shows the above posts in the same way. Same browser too. Firefox 1.5.0.4. So I don't think it is random as such.
Thanks. I use Ubuntu and Windows. I'm looking for a shell script that does this. But I'll try what you're saying as well. Thanks.
Shell scripting is much easier. But this is not the forum for that. There is a UNIX support forum for scripting in daniweb. But you could try this.
#!/bin/bash
pathA='/blah/blah/blah/'
pathB='/blah/blah/blah/blah/'
ext="deb"
for file in $(ls "$pathA"); do
#
# Only process DEB files.
#
file_ext=${file##*.}
case $file_ext in
deb | DEB )
if [ -e "$pathB$file" ]; then
echo deleting "$pathB$file"
rm -f "$pathB$file"
fi
esac
done
You're really making it tough for me ... it happens some of the time on some of your computers but I never experience it on any of my windows machines or my mac in IE, Firefox, or Safari web browsers. :(
Yeah Dani. I understand. You can't debug a problem unless you can reproduce it in your side. All I can say is that some posts always give that problem in the same computer (for example the post I showed still gives me the same problem on my laptop), and some do not give it at all. Anyways I can live with it. Just keep your eyes open when you browse the C/C++ section. maybe you will find a post that is like that on one of your computers too.
Or you could come see it for yourself...ready to make a trip to Japan :cheesy: ?
Thanks a lots...i worked with similar sprintf() function in MATLAB but didnt know similar function exists in C also....
MATLAB is more or less like C, so most functions in MATLAB are available in C.
anyways relating to the xml code link that you gave that day.....it was in German(maybe)..so i couldnt understand the comments...
Damned if I knew either. More like Dutch I suppose.
... but the initial code in that xml file said for(i=0;i<5;i++) but you corrected it to for(i=0;i<3;i++) and the program wirked ...could you tell me what was the problem with initial code...........Please
Thanks
The line that should be parsed was <Pindala> 83858km² </Pindala><Rahvaarv>8 116 000</Rahvaarv>
So after searching for the Word Pindala
, we should stop at the word Rahvaarv
, because that is processed in the next part.
if (strcmp(pos, "Rahvaarv") == 0)
That means starting from the word P, how many delimiters should we parse to get to Rahvaarv? [B]<[/B]Pindala[B]>[/B] 83858km² [B]<[/B]/Pindala><Rahvaarv>8 116 000</Rahvaarv>
The answer is 3. The ones in Blue are taken care of by the pos = strtok(rida,"<>");
at the beginning.
So you should have 3 strtoks.
Those 3 are
if (strcmp(pos, "Pindala") == 0)
{
for (i=0;i<3;i++)
{
pos = strtok(NULL,"<>"); // Called 3 times
So that makes 3. If you put 5, it would stop somewhere after Raahvarv and you will not be able to parse the values needed in the next if statement. Anyway I suggest you look at how strtok …
I don't know. The forums I read use only code tags. I checked some posts in the PHP section, but they looked fine. But then again, I don't see this problem for all posts with code tags, so can't be sure.
Is a early system of memory management.....
Each program loaded in its entirely into memory and allocated as much contiguous memory space as needed
So only a program can run at one time....
Also, if a program is too large for the memory,
it can't run.....
For single-user system, it need 2 hardware:
1) Register to store base address
2) Accumulator to track size of program as it is loaded into memoryCorrect right?
I told you no lecture notes, but the answer is accepted.
I not really know about constant parameter in single-user memory system coz my lecturer didn't say 'bout it....
Yup...I'm taking OS course......
But I 'll try to answer it....
For me constant variable are total memory size and base register....
Good. You are doing fine.
The base register is not needed for the simulation, so I will discard it.Also I will add an additional constant called NUMER_OF_BYTES_PER_INSTRUCTION.
Now you add the following constants in C++ to the int main
function I gave you earlier.
Total Memory Size - You can use any realistic value
Number of bytes per instruction - This is also any realistic value you like.
Also tell me the input needed from the user to simulate the job loading function, and the other variables that will be used while the program is running.
Yesterday was just not England's day. Both in Cricket and Football. Losing Owen was bad enough. But also without Beckham and Rooney, I'd say it is expecting too much from them. Too bad. I would have liked to see England win. But the dissapointment faded to see France win over Brazil. You could see that France controled the game since the start. If France played like they did yesterday, I think they will lift the cup.
Hmm ... only when your computer is under heavy load? Is it possible it's a browser rendering issue on your end. What would be great to know is if the same post sometimes displays it and sometimes doesn't. That will let me debug whether it's a condition on my end that is causing this problem or not.
Okay. Got this problem again. See the image attached. I always get it for that particular reply in this thread. The other replies for the same thread are not affected. Only the one I have shown. Also I dont get it in my desktop computer. Only in my laptop.
I think this will be a tough one Dani.
what if each time i need to load a different XML file...say...xyz1 then xyz2 then xyz3 and so on.....i.e open first xml file(xyz1) read it open next(xyz2)....and so on but in a loop so could you tell me how to increment the name of xml file in each loop..i.e xyz1...then xyz2.....which C functions can do this
Thanks
You will have to create the filename by using a function like sprintf
or snprintf
. snprintf
is much safer.
something like
for ( int file_number = 1; file_number<= 3; file_number++ )
{
char filename[ 20 ] = "";
snprintf( filename, 19, "xyz%d.xml", file_number );
printf("%s\n", filename );
// pass filename to your xml file opening function
}
should do the trick.
You must be in an operating systems course. Now I want you to explain me what are the characteristics of a Single-User Memory System. I don't want your lecture notes copied and pasted here directly. I already have them with me. I want your explaination in your own words.
Then tell me what are the constant parameters of a given Single-User memory system.
As for the code, let's start by learning this simple correction.
#include<iostream> // Not <iostream.h>
int main() // Not void main()
{
return 0; // This is not necessary, if this is omitted the standard assumes that main returns 0. But to be explicit just add this.
}
Let's work on the other parts as we go on.
Okay that's it. Nobody is going to spoon feed you. If you are weak in C++, you study. If you can't do an assignment, you don't take it. If you have this assignment for a course you don't enroll in it. This is not anybody's free homework service. You try it first, and post it. Not just the above pseudocode written inside code tags and a main function. It should be pure C++. Unless the reply is satisfying enough no further help will be offered.
Okay. Study this.
#include<iostream>
const int TOTAL_PARTITIONS_IN_MEMORY = 10;
enum STATUS{ FREE = 0, BUSY = 1 };
int main()
{
// This is the array that stores the memory partition size
int memory_partition_size[ TOTAL_PARTITIONS_IN_MEMORY ] = { 1 };
// This is the array that stores the memory partition status
// It is initialized to be free at the beginning
STATUS memory_partition_status[ TOTAL_PARTITIONS_IN_MEMORY ] = { FREE };
// initializing the memory partition sizes so as a partition is
// double the size of the previous partition
for (int i = 1 ; i < TOTAL_PARTITIONS_IN_MEMORY ; i++ )
{
memory_partition_size[ i ] = memory_partition_size[ i-1 ] * 2;
}
// here we go until infinity or
// the user enters a negative number or 0
// whichever comes first.
int job_size = 0;
while ( true )
{
std::cout << "Enter the job size in bytes " ;
std::cin >> job_size;
if ( job_size <= 0)
{
std::cout << "Only Positive Non-zero Job Sizes allowed\n";
std::cout << "Exiting program\n";
break;
}
// Check if the job size is greater than the largest partion size.
// The largest partition is the size of the final partition.
if (job_size > memory_partition_size[TOTAL_PARTITIONS_IN_MEMORY - 1] )
{
// If it is larger then inform that to the user and get the next job
std::cout << "Job Size is larger than the maximum partition size\n";
continue;
}
// The partition can fit a memory partition. Now find that partition.
for ( int …
Okay. But I am not going to write anything. I will go with you step by step, and you write the program.
First of all, you write the main function in C++, and post it in your next reply. Nothing fancy, just the main function.
Well, it looks pretty straightforward. Do you know any C++?
What do you mean by inheritance in real life? The child gets what his parents have if they let him have it. That is the same in programming too.
If you have a class A, whose child is class B, class B gets the things class A that has been declared public or protected by the programmer. Anything declared private will not be inherited.
What is the difference between “overloading” and “overridding”?
“overloading” is having the functions (methods) with the same name but different signatures. You can find overloading in non object oriented languages like C too. Overloading acts on different data types in different ways.
“overriding” is having a methods with same name and same signature in a parent class and the child class. You cant find overloading in non-object oriented languages like C, because they dont have a class concept. Overriding acts on different object types in different ways.
I think the best way to do it is using a float array.
float valueA[ 4 ] = { 12.2 , 11.5, 14.9, 17.9 };
For example when a == 3,
cout << valueA[a - 1] ;//<<< this would be seen as valueA3
I think you understand why I put a - 1, instead of just a. Also you should make sure that the value a can get is greater than 0, always. Otherwise a -1, will be -1, and give you an out-of-bounds error.
Here is an XML file and a C++ program that processes it. XML file structure is user defined. So this won't work for your XML file. But you can get an idea on how to proceed by studing this example. Now you figure how to do it for your XML file on your own.
Um. I think you got it confused dragon. He is infact looking to read an XML file. So I think your first link is correct.
Right now, I am not experiencing it, but I remember seeing those lines in my browser. Not always though. Either when my computer or network is on a heavy load.
Ahh, alright. BTW what does your signature mean?
One Ring to Rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them.
Lord of the Rings - page 272
Well no special interest in those things. Same as stars. Just wanted to clarify what happened. That's all. Didnt even realize I was missing my stars until I saw this thread. It was then that I "Really saw Stars". Your Highness.
It's okay. I dont need a badge. I got myself a crown.
that means I lose my 3 stars?
oh well. no big deal. who needs those stars anyway. Sour in the first place. no biggie. who cares. honest. I have my name in bold. Now that is something.
There used to be a dialog box style (DS_SYSMODAL) that created a dialog box in system modal mode. But it is only there for compatibility with 16bit windows and doesn't prevent the user from clicking other items on the desktop. So I guess you will have to intercept the mouse messages. But even then the user will be able to move through dialogs using the Alt+Tab combination. So you better look at How to Disable Task Switching.
Q1. Who wrote the book 'Bread, Beauty & Revolution' ?
(a) Karl Marx
(b) Peter Halbraith
(c) Khwaja Ahmed Abbas
(d) Jack Welch
Q4. Which south American snake's name means 'Elephant' in Tamil ?
(a) Sidewinder
(b) Viper
(c) Anaconda
(d) King Cobra
Q5. Which famous footwear's name is taken from Roman goddess of victory ?
(a) Nike
(b) Reebok
(c) Adidas
(d) Lotto
Q6. Which batsman holds the world record for scoring maximum first class centuries ?
(a) Len Hutton
(b) Jack Hobbs
(c) Graeme Hick
(d) Sunil Gavaskar
Q7. Which test cricketer has been associated with winning maximum number of test matches ?
(a) Steve Waugh
(b) Clive Lloyd
(c) Vivian Richards
(d) Don Bradman
Q8. 'Swirl, Sniff, Scrutinise & Sip' are the four S's for judging which product ?
(a) Coffee
(b) Vodka
(c) Milk
(d) Wine
Yeah you will have to buy a Windows XP CD. Also you will have to search for the Driver CD for the hardware too. For the time being you can get the computer running with only the XP CD.
From your pm I got the following specs for the Dell Dimension 4550
120GB hard drive,
64MB GeForce4 MX 420-based card to a 128MB ATI Radeon 9700 TX
2.67-GHz Pentium 4 processor,
memory from 256MB to 512MB
Are these correct to your knowledge?
Anyway since you are doing a clean install it is not that problematic. You will have to have a operating system installation CD. I think Windows XP will be the best choice. Can you get a WinXP installation CD?
Cool. Chat sessions on what topics? I have been to IRC chat a few times, but there were not much users, and the ones online didn't reply. :sad:
Do you have data that should be backuped stored in that computer? If you dont have any data that you need, you can do a clean install by reformatting that hard drive. That will be the easiest. Keep me posted.
Edit.
Oh and tell me if it is a desktop or a laptop. And whether you have an Operating System installation disk. Better if you can give me the Dell model number too. Then I can lookup in the dell site for the hardware specifications.
Training Day
Poseidon
Wild; I never knew that. Must not have caught the right episodes.
The weirdest thing is that you actually retained that obscure little factoid-
Methinks that your mind must be an *ahem* interesting neighborhood to wander around in...;)
Wanna guess who Dani's Teenage Crush was? :lol:
So, does this mean that you can access the Windows API using, say, C#.NET? Like, if I wanted to change the wallpaper, populate an Excel spreadsheet with data etc ?
The Windows API is only a function library. And it is possible to use the API functions using C#. Changing the wallpaper is API stuff, so that is possible. But excel programming is not directly related to Windows API programming. But it is possible using C# too.
Will most Windows programming be done using .NET from now on? I mean, will any of the .NET languages be enough, or is there still a need to programme to a Windows API using something like C++?
Yeah. .NET will be the future windows programming platform. C++ is also one of the so called .NET languages. It is called managed C++ to run on the .NET Platform. All the syntax is more or less the same. There are some differences when building the project, but most of that will be taken care of when you use the Visual Studio Environment.
Or is C++ (not C++.NET) necessary to really programme Windows at that level?
As I said there is no much difference in your level for Standard C++ and C++ .NET. If you dont know C++, I would not recommend learning C++ just to do windows programming. You should consider learning C#. C# presently has a good value in the programmer market. It is much easier to program for windows using C# than C++ or C. And since you have a Java background, it will be a smooth transition as C# and Java are pure OO languages and the structure is similar. Get a good C# book that has "Windows Forms Programming" as one of it's contents. I hear that Charles Petzold has a good Windows Forms Programming book in C#. Or you can have a look by googling for "Tutorials in Windows Forms Programming in C#" or something in …
I'm receiving the string like:
%E6%97%A5
this is equal to one chinese letter:
星
The Unicode for '星' is 0x66F1;
you can confirm that by running
int _tmain(int argc, _TCHAR* argv[])
{
wchar_t blah = 0x661F;
return 0;
}
under a debugger and inspecting what is stored in blah by applying a debug point at the return statement. It should be '星'.
I receive the string "%E6%97%A5" and I should return the string like this '星', convert the escaped string to a unescaped string.
From what I understand all that URLUnescape does is extract the unicode information of the encoded string and give you this unicode string. For example %20 is space character (unicode 0x0020 ). So what is expected for "%E6%97%A5" is 3 characters of unicode values
0x00E6, 0x0097, and 0x00A5. Now if you look up the characters for those values in a unicode table, you get
0x00E6 = 'æ'
0x0097 = <control char>,
0x00A5 = '¥' (Yen Character)
So I think what you get IS the correct unicode string.
Where do you dig these 2 year old threads from? I am closing this thread.
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
// declare variables
string firstName[5];
string lastName[5];
double totalSales[5];
double TotalSalesByAll = 0.0;
double bonus[ 5 ] = { 0 };
double avgsales;
// Read in the Names, and weekly sales
for ( int i = 0 ; i < 5 ; i++)
{
cout << "Enter the First Name ";
cin >> firstName[i];
cout << "Enter the Last Name ";
cin >> lastName[i];
cout << "Enter the Weekly Sales ";
cin >> totalSales[i];
TotalSalesByAll += totalSales[i];
}
// Calculate the Sales average
avgsales = TotalSalesByAll / 5;
// Calculate the bonus amount.
for (int i=0; i < 5; i++)
{
if ( totalSales[i] > avgsales )
{
bonus[i] = totalSales[i] * 0.05;
}
else
{
bonus[i] = 0;
}
}
// Display
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout << "\n\n Sales Report\n\n";
cout << " First Last Total Sales Bonus \n";
cout.width(15);
cout << firstName[i];
cout.width(10);
cout << lastName[5];
cout.width(10);
cout << totalSales[5];
cout.width(20);
cout << bonus[5];
cout << endl;
return 0;
}
The lines marked in Red are definitely wrong. The line marked in Blue is neither right nor wrong. Refer the tutorials in Arrays a bit more. If you define an array called
int integer_array[ 5] = {10, 22, 31, 48, 12};
how do you print the 5 elements in integer_array
to the screen? When you figure out the way to answer that question you will realize what you are doing wrong.
#include <iostream>
#include <string>
using namespace std;
int main()
{
// declare variables
string firstName[5];
string lastName[5];
double totalSales[5];
double TotalSalesByAll = 0.0;
double bonus[ 5 ] = { 0 };
double avgsales,
// Read in the Names, and weekly sales
for ( int i = 0 ; i < 5 ; i++)
{
cout << "Enter the First Name";
cin >> firstName[i];
cout << "Enter the Last Name";
cin >> lastName[i];
cout << "Enter the Weekly Sales ";
cin >> totalSales[i];
TotalSalesByAll += totalSales[i];
}
// Calculate the Sales average
avgsales = TotalSalesByAll / 5;
// Calculate the bonus amount.
for (int i=0; i < 5; i++)
{
if ( totalSales[i] > avgsales )
{
bonusAmount[i] = totalSales[i] * 0.05;
}
else
{
bonusAmount[i] = 0; // this is unnecessary actually
}
}
// Display as you want. I stop here.
return 0;
}