|
First of all: Casting happens implicitly so you don't need to cast in this scenario.
Secondly: These types that you are specifying in non-standard types, so uint32_t could be defined as anything which will give you an incorrect result.
Thirdly: How to you check what the result is? Though debugging or though a print statement? The print statement could be wrong.
Fouth: Know your platform you writing the code for (its limitations and the standard it is using). Not necessarily that the pic32 uses the specific c standard which you are looking at.
"Program testing can be used to show the presence of bugs, but never to show their absence."
<< please vote!! >></div>
|
|
|
|
|
It is possible to change the text of an menu item who has another branch menu ? I have tried classical solution:
pCmdUI->SetText(_T("&aaaa"));
but is working only on simple menu item ... if from this menu item go another menu items branch, the text have not change it ...
|
|
|
|
|
It should work, but if you have a resource based menu it's possible the system is refreshing it from your resource details.
|
|
|
|
|
I put a TRACE macro inside of ON_UPDATE_COMMAND_UI handler, but strange, it doesn't call at all ... that is why the text is not changing ... this message (ON_UPDATE_COMMAND_UI) is not calling for menu items that has derived menu from itself ?
|
|
|
|
|
Did you add their control ids to the set that the ON_UPDATE_COMMAND_UI responds to?
|
|
|
|
|
Yes, I did:
ON_UPDATE_COMMAND_UI(ID_VIEW_RENDERER1PLAN, &CMyAppDoc::OnUpdateViewRenderer1plan)
The fact is when I change menu item functionality, from this state (when from this menu is derived another menu item) into simple menu item, the text changing is working ...
|
|
|
|
|
It is difficult to guess what may be happening in your code, but changing the text of a control should have no effect on the message passing and event handling for that control. I would try it myself but do not have MFC on my system.
There is also some useful information at https://msdn.microsoft.com/en-us/library/65dtx4a4.aspx[^].
|
|
|
|
|
have this code in secure shell
and I want to keep log of the users input
I fopen the file in the beginning
and fprinf on the data specific that needs to be written
then at end of file I fclose it
the problem is that its not writing the file
when I cat gamelog it just sends me to the next calling line
??????
|
|
|
|
|
|
Member 12084559 wrote: ?????? We have the same question!
What does the code look like? You've told us what you want, and what is actually happening, but without seeing the code, it's anyone's guess.
"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
|
|
|
|
|
creating a battleship game with log in. Need to know how to create a file that will check if login is correct. then be able to fprintf so I can use login file.
only need login name not password
thanks
|
|
|
|
|
Are you asking how to write a program from soup to nuts, or are you asking about a specific issue?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
|
pretty much soup to nut if you wanna put in that inference. I'm new to programming and I cant grasp the concept of either one.
Im making a battleship game which calls for a gamelogfile and a gameboard file from which i have to read from.
I have to be able to use the gamelogfile to check whether or not the users name is correct. and also for it to be able to store the names of each user.
|
|
|
|
|
Member 12084559 wrote: I'm new to programming and I cant grasp the concept of either one. Then it is most unlikely that you are going to succeed in creating a battleship game. I suggest your time would be better spent finding some decent books/tutorials etc and working through them in order to build up a reasonable knowledge of the basics.
|
|
|
|
|
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main (void){
FILE* gamein;
int numIn=0;
int row=0;
int column=0;
float Use=0;
int gameinput_array[5][5];
//output
for(row =0; row<5; row++){
for(column=0; column<5; column++)
fscanf(gamein, "%d", &numIn); //have two fscanf's 1st
gameinput_array[row][column]=numIn;
}
//
gamein = fopen("gameinput", "r");
while((fscanf(gamein, "%d", &numIn))==1) // 2nd
printf("%d", numIn);
char gamelog_file[30];
FILE* gamelog;
printf("Enter Your User Name here\n");
scanf("%s", &gamelog_file);
//gamelog=fopen(gamelog_file,"a");//append
return 0;
}
NOW IM DRAGING BORAD INFO FORM gameinput FILE* WHICH HAS JUST LINES OF 0'S AND 1'S 5*5 GRID
NEED TO KNOW ABOUT THE FSCANF'S, WHETHER THEY ARE CORRECT OR NOT
WHEN THIS CODE COMPILES I GET SEGMENTATION FAULT BUT IT DOES COMPILE
THANKS IF YOU CAN HELP
|
|
|
|
|
Member 12084559 wrote: fscanf(gamein, "%d", &numIn); //have two fscanf's 1st
gamein has not been assigned to an open file yet. Why?
Member 12084559 wrote:
WHEN THIS CODE COMPILES I GET SEGMENTATION FAULT... Where? Have you stepped through the code (line by line) using the debugger?
"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
modified 26-Oct-15 8:07am.
|
|
|
|
|
no I ended up fixing it by moving the two for loops down after the read file.
do you know how to call from the gamefile and allow the user to call each coordinate so they can enter each coordinate they choose to try to sink the ship.
i Know i have to use if and else statements i just don't know how to integrate them into the file.
|
|
|
|
|
Member 12084559 wrote: i Know i have to use if and else statements i just don't know how to integrate them into the file.
Priceless! You just made my day, sir!
Best,
John
|
|
|
|
|
I refer you to my previous comment. There is very little loigical structure to your code, and some fairly basic and obvious mistakes. You should write an outline of your program requirements and try to think in terms of using function subroutines for specific tasks, rather than writing everything inline. Only when you have that structure should you start writing the actual code.
|
|
|
|
|
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
|
|
|
|