|
Hell, why don't we just wipe the CP server and hand the space over to MSDN? Sure they coudl use it to hold allllll of those answers.
|
|
|
|
|
then, let's close this forum...
|
|
|
|
|
Please help me to create an array which is coming from txt file...
Here is my code so far...
#include "stdafx.h"
int _tmain(int argc, _TCHAR* argv[])
{
FILE *input; // declare a pointer of type FILE
char input_char; // a single character
#define width 15
#define height 40
char buffer[width][height]; // a buufer array
int n,m;
// ******** open
input=fopen("D:\\Documents and Settings\\wzq2gn\\My Documents\\Old pc\\Ferdy's File\\Lecture 3 Examples\\customer.txt","r");
for (n=0;n
|
|
|
|
|
And what exactly is the problem ??
Also, use the pre or code tags (just above the emoticons) when you post code. And don't forget to replace the < and > symbols in your code by the tags also (or you can select 'Ignore HTML tags')
|
|
|
|
|
|
Your code snippet would be that much more readable had you enclosed it within <pre> tags.
So what is the problem you are having?
wzq2gn wrote: buffer[n][m]=fgetc(input);
It'd be much more efficient to at least use fgets() , rather than read one character at a time.
wzq2gn wrote: printf("%c,%c ",buffer[n][m]);
This tells printf() to print two characters, but you are only supplying one.
"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
|
|
|
|
|
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
|
|
|
|