|
I need to use the fgetc for single character manipulation.
How do I get the contents of the array using printf?
|
|
|
|
|
wzq2gn wrote: I need to use the fgetc for single character manipulation.
Using fgetc() is very costly in terms of disk I/O. The fact that you need to do "single character manipulation" has nothing to do with using fgetc() . You could read the entire file into memory using one call to fread() and then operator on the character buffer.
wzq2gn wrote: How do I get the contents of the array using printf?
printf() is used to print, not get. The format string governs how many variable arguments are passed to it. In your code snippet, you were only passing one, but two were required.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Do your requirements require a C-style implementation? That is, why not use the standard C++ libraries?
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Your code was incomprehensible and you didn’t explain properly what you were trying to do so I took a guess. You should spend some more effort making you code intelligible, especially if you’re asking others to look at it. Anyway forget about old C functions such as “fgetc” and raw arrays. Here’s my program in C++:
----------------------
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
int main(int argc, char *argv[])
{
using namespace std;
// Open the input file.
ifstream iff("C:\\a.txt");
if (!iff)
{
cerr << "Failed to open input file!" << endl;
return 1;
}
// We'll store the file's contents in a 'vector' of 'string's.
typedef vector<string> FileContents_t;
FileContents_t fileContents;
// Read in the file line by line and add each line to 'fileContents'.
string line;
while (getline(iff, line))
{
fileContents.push_back(line);
}
// Now we can access any character in the file by its row and column.
unsigned int column = 5;
unsigned int row = 4;
if (row>=fileContents.size())
{
cerr << "Row out of range!" << endl;
return 1;
}
const string &ourRow = fileContents[row-1];
if (column>=ourRow.size())
{
cerr << "Column out of range!" << endl;
return 1;
}
char c = ourRow[column-1];
// Output the results.
cout << "Char at row " << row << " column " << column << " is " << c << endl;
return 0;
}
Steve
|
|
|
|
|
Thanks Steve and all the people who contributed for my C++ fiasco...
|
|
|
|
|
hi all,
CMAPIAdviseSink::OnNotify(...) will give the notification of email, Please let me know the steps to be followed to get the Notification of Messages when a Mail is Send to your computer.
Uday kiran
|
|
|
|
|
See here.
"Talent without discipline is like an octopus on roller skates. There's plenty of movement, but you never know if it's going to be forward, backwards, or sideways." - H. Jackson Brown, Jr.
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi!
How can I take path to current folder.
Example.
I rum my program from c:\Program\Demo\
How can I take this path.
|
|
|
|
|
|
maybe I should hit my refresh button more often :p
|
|
|
|
|
.... LOL .....
Regards
Programm3r
|
|
|
|
|
Work
Tank You very much!
|
|
|
|
|
|
GetCurrentDirectory();
KIRAN PINJARLA
|
|
|
|
|
Retrieves the current directory for the current process.
<br />
DWORD GetCurrentDirectory(<br />
DWORD nBufferLength,<br />
LPTSTR lpBuffer<br />
);<br />
Regards
Programm3r
|
|
|
|
|
<br />
GetModuleFileNameEx()
GetCurrentDirectory()
SetCurrentDirectory()
GetWindowsDirectory()
GetSystemDirectory()
|
|
|
|
|
Hi,
I need send mouse message (click, mouse move...) to child window. I have main dialog and this
have child dialog. Do you know whether exist some automatic message??? Or I must send these messages
to the Child by mean code??
Thanks
|
|
|
|
|
majco333 wrote: Do you know whether exist some automatic message???
What do you mean by this?
you can use SendMessage, given handle to window, for sending messages to that window.
|
|
|
|
|
Whether do not exist some message or switch whitch send messages from parent to child..
I have child window in ActiveX control
|
|
|
|
|
What do you need,exactly?and see SendMessage(...) (WM_LBUTTON*)and do you want to send one message (WM_MOUSEOVER) from main dialog to child dialog,right?
|
|
|
|
|
I need to handle mouse move when is out of child window too...
I handling mouse move in Child window but when I am with mouse out of child window, do not go me message... Do you know how do it?
|
|
|
|
|
majco333 wrote: I need to handle mouse move when is out of child window too...
Why this is required, can you explain ?
You can trck when mouse leave message, but not sure about other.
|
|
|
|
|
|
WM_MOUSELEAVE, when mouse leaves the windows client area
|
|
|
|
|
ON_MESSAGE(WM_MOUSELEAVE,OnMouseLeave) is not function me
|
|
|
|