|
So how do I create a 256 color DC ?
|
|
|
|
|
When I try to use the following code to write every possible combiniations between 00 and 99, I don't get the same result as ostream. What could be the problem?
for (int a=0; a<10; a++)
{
for (int aa=0; aa<10; aa++)
fprintf(outClientFile, "%d\n", a);
fprintf(outClientFile, "%d", aa);
}
|
|
|
|
|
Andrew Admire wrote:
What could be the problem?
You did not indicate the difference between the two but I would lean towards caching.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
How would I tell the prog the difference?
|
|
|
|
|
Tell the difference between what? All you need to do is use endl with cout . That flushes the output buffer.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
for (int a=0; a<10; a++)<br />
{<br />
for (int aa=0; aa<10; aa++)<br />
{<br />
fprintf(outClientFile, "%d%d\n", a,aa);<br />
}<br />
}
But, will be better to do this :
for (int a = 0; a < 99 ; a++ )
{
...
}
Ivan Cachicatari
www.latindevelopers.com
|
|
|
|
|
The only problem is that i want to display 00, 01, 02, 03...
|
|
|
|
|
You can do that by simply doing
fprintf(fFile, "%02d\n", dwIndex);
The "2" means set a width of 2 places for the number and the "0" means fill in the places not used with 0.
So the following should print 00, 01, 02, ...
for(dwIndex = 0; dwIndex < 100; dwIndex++)
{
fprintf(fFile, "%02d\n", dwIndex);
}
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
Then,
This code is the solution:
for(int i = 0 ; i < 100 ; i++)
{
for(int j = 0 ; j < 100 ; j++)
{
fprintf(outClientFile,"%0*d%0*d\n",2,i,2,j);
}
}
Ivan Cachicatari Blog[^]
www.latindevelopers.com
|
|
|
|
|
Then here is my next problem. I am tring to do the same thing with letters.
AA, AB, AC...
char string1[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','\0'};
for (int a=0; string1[a] != '\0'; a++)
{
for (int aa=0; string1[aa] != '\0'; aa++)
fprintf(outClientFile, "%02s%c", string1, '\n');
}
|
|
|
|
|
Is this homework?
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
No, I made a command-line version of a dictionary file creator. However, using the ostream commands, the file won't go above 4 Gb. Someone said to try the fopen and fprintf commands. I never used them that's why. I'm new at programming and I love it. So, I'm trying to push my knowledge.
|
|
|
|
|
char cCharacter1, cCharacter2;
for(cCharacter1 = 'A'; cCharacter1 <= 'Z'; cCharacter1++)
{
for(cCharacter2 = 'A'; cCharacter2 <= 'Z'; cCharacter2++)
{
printf("%c%c\n", cCharacter1, cCharacter2);
}
}
Alternatively you could do it with 1 loop incrementing a number from 0 to 26*26 where one character is printed using Number/26 = Integer Truncate Decimal and the other character is generated using Number % 26 to get a mod of 0 - 25. Then you just add 'A' onto the number to get the character or use it as an index to your array.
8bc7c0ec02c0e404c0cc0680f7018827ebee
|
|
|
|
|
char string1[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q',
'R','S','T','U','V','W','X','Y','Z','\0'};
int len = strlen(string1);
for (int i = 0; i < len ; i++)
{
for (int j = 0; j < len ; j++)
{
fprintf(outClientFile,"%c%c\n",string1[i],string1[j]);
}
}
}
Ivan Cachicatari
www.latindevelopers.com
|
|
|
|
|
it is because you don't flush the cout stream.
you can either do (as Mr DavidCrow suggested) cout << ... << endl; where endl does the same as printing a '\n' plus flushing the stream,
or just call cout.flush(); after the cout << ... << '\n';
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
One last thing. I was able to create the file larger than 4 Gb. However, I want to be able to read the last line to see where it stopped. This code outputs the whole file but works when the file is less than 4Gb. What's wrong?
If you want me to start another thread let me know.
Thanks,
ifstream inClientFile ("diction.txt", ios::in);
inClientFile.seekg(-10, ios::end);
char w[7];
while (inClientFile>>w)
output(w);
void output(const char * const w)
{
cout<
|
|
|
|
|
Andrew Admire wrote:
If you want me to start another thread let me know.
hum, yes, i think you'd better, till i can't help you there...
tell me anyway, you create a char[7], but do all the words in your dictionnary are smaller than or equal to 6 characters (don't forget the trailing '\0') ?!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Originally I had it set to 30. Even then it only worked when the file it was reading was less than 4Gb.
|
|
|
|
|
Hello! I'm meaning to write a simple app in Visual C++, though I'd like to give it a different "skin" than the standard Windows apps. Is there some sort of (free, preferably ) lib out there that enables you to create custom looks for buttons/menus/scrollbars so I can focus on the simple app?
Any help would be.. helpful
/Vanne
|
|
|
|
|
|
You can try AppFace User Interface Development Kits . Download it here, http://www.appface.com
|
|
|
|
|
i'm developing an application to interface some board with pc using usb port. i've to develop upload, download data and disconnect feature. can i hgot some application code in vc++ how to link it with existing windows driver and write application code
vikas makhija
|
|
|
|
|
There is not a standard way to communicate with any USB device. If manufacturer doesn't give you the frames' format specification, or an API, I guess you won't do it.
If you want to learn about USB programming, I suggest you to buy the book "USB Complete" by J.Axelson
Jaime
|
|
|
|
|
I want to a send file from my PC to the PC in my university through sockets. How do i get the unique ip for my pc connected to internet via LAN. The packet does not the reach the destination(ip of the pc connected to LAN), probably it is discarded for some security purpose. I want to understand the reasoning of the problem & the solution. Please help me
Regards
|
|
|
|
|
Are you natted? This way it is not possible to reach your PC. You are behind firewalls and NATting devices, that only have a selected amount of public addresses and a significant amount of internal IP addresses. Sockets dont have much to do with it.. IP rather.
"live life one cpu cycle at a time".
|
|
|
|
|