|
Hello,
I have the basics of programming but no idea how to code nowadays. I would like to make an executable or service, or something that allows me to turn off the wireless connectivity if laptop is connected physically using the port. And if laptop gets unplugged from the physical lan, then the wireless nic becomes active until connects to a wifi network. In other words, would like to make something like a connection switcher. Have no idea, where to start.
Thanks for your advice and guidelines.
|
|
|
|
|
See here.
"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
|
|
|
|
|
|
I'm not sure if I can ask this here because it is for an open source library called Podofo. I'm asked this on their mailing lists but it could be some time before someone responds. If this is the wrong place to ask this question then please let me know and I'll just remove it. I was hoping that maybe someone else out there uses this library and has some experience in dealing with this problem.
The function PdfFontMetrics::GetGlyphID should return the Glyph ID for a given character represented by it's unicode codepoint (as a long).
To make things easier I have written a small program greatly simplifying and hopefully clarifying my problem. I hope I haven't over simplified things but the PdfFontMetrics object seems to work in some case but not when looking for the Glyph ID. This is a small command line program. For now, it's whole purpose is to find the Glyph ID for each character handed to the GetGlyphID function. There are some other output messages in there to prove that the PdfFont has been loaded.
This library uses Freetype2 as a dependency and when using the GetGlyphID function it eventually calls the FT_Get_Char_Index( FontFace(this is preloaded), Unicode(unicode value codepoint) ) which is a Freetype function as part of it's API. One of the fonts, represented as Font Name: LNCKCK+TimesNewRomanPSMT represents the one of the preloaded font names my program searches for when seeking the Glyph ID. I'm assuming that this isn't found because the GetGlyphID function is telling me that it can't find the Glyph ID by returning Zero. It is highly likely that there is some problem with the font name and thus the glyph search ends early.
Here's the code. Please see the comments below where I have extracted the TJ array and attempt to find the Glyph ID for individual characters. The line commented with
"// NOW ATTEMPT TO EXTRACT GLYPH INFORMATION" is where I try to get the Glyph ID. I just can't see where I'm going wrong. Can anyone help? Thanks
#include <iostream>
#include <string>
#include <cstdlib>
#include <podofo/podofo.h>
#include <stack>
using namespace PoDoFo;
using namespace std;
PdfMemDocument doc;
int page_count;
PdfPage *page;
EPdfContentsType type;
PdfVariant var;
const char* token;
PdfFont *Font;
const PdfFontMetrics *met;
PdfArray pArray;
int size_of_array;
string TJ_string;
stack<PdfVariant> PdfStack;
long GlyphID;
int main(int argc, char **argv)
{
try{
doc.Load(argv[1]);
page_count = doc.GetPageCount();
for(int i = 0; i < page_count;i++)
{
page = doc.GetPage(i);
PdfContentsTokenizer tokenizer(page);
while(tokenizer.ReadNext(type,token,var))
{
if(type==ePdfContentsType_Keyword)
{
string keyword;
keyword = token;
if(keyword == "Tf")
{
PdfStack.pop();
PdfName name_of_font = PdfStack.top().GetName();
PdfObject *ofont = page->GetFromResources(PdfName("Font"),name_of_font);
Font = doc.GetFont(ofont);
met = Font->GetFontMetrics();
}
if(keyword == "TJ")
{
pArray = PdfStack.top().GetArray();
PdfStack.pop();
size_of_array = pArray.GetSize();
for(int x = 0; x < size_of_array; x++)
{
if(pArray[x].IsHexString()|| pArray[x].IsString())
{
TJ_string = pArray[x].GetString().GetString();
for (int s = 0; s < TJ_string.length(); s++)
{
unsigned char individual_character = TJ_string[s];
cout << "Font Size is: " << met->GetFontSize() << endl;
cout << "Character Width is: " << met->CharWidth(individual_character) << endl;
GlyphID = met->GetGlyphId((long)individual_character);
cout << "************************* THE GLYPH ID IS: " << GlyphID << endl;
}
}
}
}
}
else if(type==ePdfContentsType_Variant)
{
PdfStack.push(var);
}
}
}
}
catch(PdfError &err)
{
cout << "The Error is: " << err.what() << endl;
}
}
|
|
|
|
|
Please Give easy articles that i can unsestand
|
|
|
|
|
Well there are lots of sites that provide access to educational articles, and Google will find them for you. Or, you could even try the CodeProject Articles section[^].
|
|
|
|
|
Please don't repost the same question; I have deleted your duplicate. If you have extra information to add, then edit this one.
|
|
|
|
|
Delete the least number of integers from a given set of integers so that the product of the remaining integers in the set is a perfect square. In case there is more than one solution then find the solution that gives the largest perfect square. Assume that each integer contains five or less number of digits. The total number of integers in the given set is twenty or less.
Input
First line will be number of test cases
The input may contain multiple test cases.
For each test case there is a single input line. The line contains the given set of integers.
Output
For each test case there is only one output line. The line simply prints the integers to be deleted in ascending order. There are two special cases; print output for these cases as indicated below.
Case 1: No integer is to be deleted: Print 0 as output.
Case 2: All integers are to be deleted: Print all integers in ascending order.
Sample Input
4
2 3 12 18 24
12 10 15 18
4 12 10 15
10 12 15
Sample Output
4
Case#1 = 24
Case#2 = 0
Case#3 = 10 12 15
Case#4 = 10 12 15
|
|
|
|
|
Sorry but we do not do your homework for you. Make an effort to do your own work and people will help you with specific problems.
|
|
|
|
|
What is your doubt about?
How would you do it with pencil and paper?
|
|
|
|
|
This reeks like homework, have you asked your instructor for help?
"I've seen more information on a frickin' sticky note!" - Dave Kreskowiak
|
|
|
|
|
Hi All.
Can any help me!
I am a MFC developer, my mission is porting from MFC to QT application. But I can not find the easy way to porting, it's so hard and maybe i lose my mission.
Can any know how to porting from MFC to QT. Please help me.
Thanks so much!
|
|
|
|
|
|
I have not done this but have written MFC and Qt applications.
Knowing both I would deny such a request because they are too different and porting is similar to rewriting the application. However, it all depends on the size of the existing application.
|
|
|
|
|
As others have eluded, I don't think there is an "easy way" to port the code over. You'll have to basically start re-writing things and solve problems as they come up. Having written things in both MFC and Qt, you may end up doing a lot of re-design since the frameworks can vary quite a bit with some things.
If you're looking for something that may be easier to port so that it works in other platforms (i.e.Linux), WxWidgets may be an easier port.
|
|
|
|
|
Hi ALL,
I am trying to get the timing exactly 2 days diff from current time.please advice i am not getting it correctly.
here is my code (-2 does not work)
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
int main() {
time_t current_time;
char* c_time_string;
current_time = time(NULL);
current_time = current_time -2
/* Convert to local time format. */
c_time_string = ctime(¤t_time);
printf("Current time is %s", c_time_string);
return 0;
}
|
|
|
|
|
http://en.cppreference.com/w/c/chrono/time[^]
Read the notes carefully.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
|
Oops! Try 60 * 60 * 24 * 2.
btw, seconds in a day is "eight six four two zeros" ie 86 400.
Cheers,
Peter
Software rusts. Simon Stephenson, ca 1994. So does this signature. me, 2012
|
|
|
|
|
Ooops. Lack of coffee.
Thank you for the correction.
|
|
|
|
|
The time function returns seconds since Epoch. In order to obtain two days back you have to subtract the correct amount of seconds, e.g.
#include <stdio.h>
#include <time.h>
#define SECONDS_PER_DAY 86400
int main()
{
time_t current_time;
char* c_time_string;
current_time = time(NULL);
current_time = current_time - 2 * SECONDS_PER_DAY;
c_time_string = ctime(¤t_time);
printf("Current time is %s\n", c_time_string);
return 0;
}
|
|
|
|
|
The C-2011 standard does not specify the epoch or the resolution of time(). The POSIX standard specifies the epoch as 1970-01-01 00:00:00, and the resolution as seconds.
The fact that most runtime libraries follow the POSIX standard should not blind you to the fact that using this function to perform date arithmetic is inherently non-portable.
If you wish to perform date/time manipulations, you should use the functions that operate on the 'tm' structure.
If you have an important point to make, don't try to be subtle or clever. Use a pile driver. Hit the point once. Then come back and hit it again. Then hit it a third time - a tremendous whack.
--Winston Churchill
|
|
|
|
|
hello everyone, i made a tic tac toe in C language, using the minimax algorithm but i have some problem when i try to play with larger matrix more than 3x3 for example 4x4 and my program go out of memory.
So i search in the net and i discover the aplpha-beta pruning that reduce the computional coast and so i can play with 4x4 matrix whiteout problems but i have not idea to implement this algorithm to my minimax.
if there is a person who want to help me i would be grateful.
sorry for my bad english but i am italian
i can post my code if you want
|
|
|
|
|
You could start (if you haven't already done) with the Wikipedia's article on the subject: Alpha–beta pruning[^].
|
|
|
|
|
 hi, i read the article on wikipedia and i understand it but the problem is that i don't know how to implement it to my minimax
here is my minimax if want to give me an idea ..
int miniMax(char wnr, int deep){
if (controlloVincita(2)) return INT_MAX;
if (endgame())
return INT_MIN;
int i, j, res, tmp;
if (wnr == 1) {
res = 1;
for (i = 0;i<M;i++)
for (j = 0;j<N;j++)
{
if (BOARD[i][j]==0)
{
BOARD[i][j] = 1;
if (controlloVincita(1))
if (deep == 20)
{
BOARD[i][j] = 0;
return INT_MIN;
}
else
res -= 2;
else if ((tmp = miniMax(2, deep - 1))<res || (tmp == INT_MIN))
res = tmp;
BOARD[i][j] = 0;
}
}
}
else
{
res = -1;
for (i = 0;i<M;i++)
for (j = 0;j<N;j++)
{
if (BOARD[i][j]==0)
{
BOARD[i][j] = 2;
if (controlloVincita(2))
res += 2;
else if ((tmp = miniMax(1, deep - 1))>res || (tmp == INT_MAX))
res = tmp;
BOARD[i][j] = 0;
}
}
}
return res;
}
int get_next_move(unsigned int *i, unsigned int *j)
{
int max = INT_MIN, mi = 1, mj = 1, t;
int alfa = INT_MIN, beta = INT_MAX;
for (*i = 0;*i<M;(*i)++)
for (*j = 0;*j<N;(*j)++)
if (BOARD[*i][*j]==0) {
BOARD[*i][*j] = 2; t = miniMax(1, 20); if (t>max) {
max = t;
mi = *i;
mj = *j;
}
BOARD[*i][*j] = 0;
}
BOARD[mi][mj] = 2; *i = mi;
*j = mj;
return 1;
}
|
|
|
|