|
The wininet library in Windows contains APIs for "cracking" and parsing network URIs into their component parts.
Are you aware of any facility in Windows that performs this function for command lines? (Something that I can call from an application, not the parsing that is done when my application is launched.)
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Are you talking about the contents of argc and argv ?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Yes, and the executable name.
I imagine each argument separated into an array, and the executable name separated.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Richard Andrew x64 wrote:
I imagine each argument separated into an array, and the executable name separated. All of that is contained in the argv vector. For the executable name, look at the 0th item.
For WinMain() , you may have to refer to __argc and __argv instead.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Thank you David.
I didn't make it clear enough at first. I meant that I want my application to be able to parse the command line of a separate process.
You know how some registry keys have command lines in them? I was wondering if there is something built into Windows that can make it easy to parse them.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Ahh, that's a horse of a different color.
If you tried separating the tokens using a space as the delimiter, an issue that I see is that the path\executable name can itself contain a space. This is usually resolved by surrounding that token with quotes. So as you are parsing the whole string, you'd need to keep track of whether you were in a quote or not. If so, then spaces do not count.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
|
Bingo!
Thank you!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Awesome. I had no idea such a routine existed.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Supposed I have a text file having the results of the 6/49 lottery in it:
49-05-13-42-18-45
43-24-36-16-39-22
32-48-05-18-34-29
13-14-07-41-48-39
47-05-17-13-37-49
06-23-34-21-46-37
06-42-13-40-11-37
39-44-40-21-32-20
17-26-38-43-01-02
How can I achieve the following output written to a text file with filename, "occurences.txt"?
49 - 2 times
49 paired with 13 - 2 times
I don't have an exact idea but maybe the following pseudocode can help:
void main ()
{
int number
cout<<"CHARACTER \t\ How many times it appeared"<<endl;
for (number='01'; number<='49'; number++)
{
cout<<number<<" - \t"<<countNumber(numbercount)<<" times"<<endl;
cout<<number<<" paired with \t"<<number<<" "<<ountNumber(numbercount)<<" times"<<endl;
}
system ("PAUSE");
return 0;
}
int countNumbers (int number)
{
ifstrem.stream; int numbercount;
int count=0;
stream.open ("countNumbers.txt"); stream.get (numbercount);
while (!stream.fail())
{
if (numbercount==number)
count++
stream.get(numbercount);
}
stream.close ();
return numbercount;
}
How can I go about this?
|
|
|
|
|
You cannot use character types that contain more than one character, like '49' . The first thing you need to do is read all the input, split the items into separate fields and convert the numbers to integers. You can then count the individual values, and the sets just by counting through all the saved numbers. You do not need to count from 1 to 49, since some of those values will not be present.
|
|
|
|
|
In additoon to what Richard said, you seem to be having a very vague understanding of C/C++ programming. Before trying your hand on a moderately difficult problem, you should really start with a tutorial on C++ programming. There are plenty of good sites on the web for this, e.g. at C++ Language - C++ Tutorials[^] You should specifically focus on the first chapter, which covers pretty much everything you need for the program you asked about.
GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)
|
|
|
|
|
I'm sure there are many ways to skin this cat, but how about a loop that reads each line of the file into a string type, then calls string::find() for things like "49-" and "-49"? If one of those is found, then do something similar with the 13. Would that work?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Good afternoon
I am new in c++. I am trying to write a code that uses an array of 2 exponent 32, A small example is the code below.
#include <iostream>
# include <stdio.h>
# include <fstream>
# include <string.h>
# include <iostream>
#include <math.h>
# include <stdlib.h>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <limits>
#define two_power(n) (1u << (n))
using namespace std;
typedef unsigned long word32;
int main()
{
word32 delta, alfa;
static word32 array[4294967295][4294967295] ={0};
for (delta = 0; delta < 4294967296; delta++)
{
for (alfa = 0; alfa < 4294967296; alfa++)
{
array[delta][alfa] = alfa + delta;
}
}
cout << array[4294967295][4294967295];
return 0;
}
I there any method I can use to instead of using array because arrays have limitation in size. 2^32 = 4294967296. You can send me an email if you have an answer
kdmuthavhine@gmail.com
|
|
|
|
|
That is just crazy, you are trying to reserve 73,786,976,294,838,206,464 bytes in your program. And given that all your program does (or tries to do) is print the numbers from 1 to that value, it is rather a waste of time. You can use a single variable and write a loop that increments it from 1 to whatever final value you want, printing each value as it goes round the loop. You also do not need most of those #include statements; only include the ones you need.
|
|
|
|
|
So you need 73.78 x 10^18 bytes? Wow! May I ask what you're using it for?
Generally I'd use a vector instead of arrays and let the vector handle the memory allocations/deallocations, but I've never had to deal with numbers that large. I can't imagine your code being able to allocate that kind of space.
The program you've posted is accessing an invalid array index, the largest index you can theoretically have is array[4294967294][4294967294], because there are 4294967295 entries in each dimension, entries 0-4294967294.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
modified 24-Apr-20 13:23pm.
|
|
|
|
|
jeron1 wrote: because there are 4294967295 entries in each dimension
Yes but he's writing his program in the fourth dimension!
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Because in the fourth dimension no one can hear your allocation fail?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
What does my question has to deal with facebook and drinking behaviour?
|
|
|
|
|
Member 14812342 wrote: What does my question has to deal with facebook and drinking behaviour?
Nothing.
It was not an answer, just a signature!
|
|
|
|
|
So what is it that has to be done. I want to create Differential Distribution Table (DDT) of Blowfish algorithm. I have done for DES.
|
|
|
|
|
for Differential Distribution Table of Blowfish algorithm
|
|
|
|
|
Well you cannot create it in memory like that. You need to rethink what you are trying to do and understand the hardware and software limitations of the system you are working on.
|
|
|
|
|
How does one invoke the File Explorer Properties dialog box in Windows 10 for a specific file from a C++ application?
EDIT:
You must use ShellExecute with a verb of "properties".
The difficult we do right away...
...the impossible takes slightly longer.
modified 24-Apr-20 10:52am.
|
|
|
|
|
Please read carefully.
I am not looking for RTFM replies.
I am getting nowhere in OpenGL forum.
I do understand this is NOT OpenGL forum.
I am NOT looking for fancy shading graphics,
I am not looking for how to retrieve object outline either.
I am looking for as detailed as possible practical flow in using OpenGL stencil.
I have bits and pieces and it is all just "try this ... try that..."
I am looking for help, not for pointless criticism of my coding style.
If you cannot help me , please dot not reply.
glPushAttrib( GL_ALL_ATTRIB_BITS);
// must clear all for resizing
// TOK resizing works !
glClear(
GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
glClearStencil(0); // why and what ???
glEnable( GL_STENCIL_TEST); // TOK
// glStencilMask is set to 1 as default (??)
//glStencilMask(0x00); // no effect
//glStencilMask(0xFF); // no effect
{
// process object block is this correct place ??
OpenGL_Render_RealAxis(); // int parameter = 0)
OpenGL_Render_Plus_IMG_Axis(); //int parameter = 0)
OpenGL_Render_Minus_IMG_Axis(5); //passed temporary last circle as parameter 5 }
// TOK turn off writing to color buffer - do no show object to be stenciled
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
// Set the stencil buffer to write a 1 in every time
// a pixel is written to the screen
glStencilFunc( GL_ALWAYS, 1, 0xFFFF);
glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE);
{
// process block dupe
OpenGL_Render_RealAxis(); // int parameter = 0)
OpenGL_Render_Plus_IMG_Axis(); //int parameter = 0)
OpenGL_Render_Minus_IMG_Axis(5); //passed temporary last circle as parameter = 0)
}
parameter_stencil = 42; // verify stencil function
parameter_stencil = Stencil(parameter_stencil);
if (parameter_stencil == 0) {
printf(
"\nTOK HERE Stencil full circle parameter %i @function %s @line %i",
parameter_stencil, __FUNCTION__, __LINE__);
glStencilFunc(GL_EQUAL, 1, 1);
} // show / keep inside circle
else {
printf(
"\nStencil last circle parameter %i @function %s @line %i",
parameter_stencil, __FUNCTION__, __LINE__);
glStencilFunc(GL_NOTEQUAL, 1, 1);
} // keep all outside of stencil
// now showing all - stencil plus object ??
glFlush();
glStencilOp( GL_KEEP, GL_KEEP, GL_REPLACE);
glutSwapBuffers(); // no change !
|
|
|
|