|
Hi,
I want to introduce Logs in my c++ program. which is faster fstream or 'c' language's FILE ? so that i can use in my logs.
Thanx in adv.
lokiz
|
|
|
|
|
FILE is not a method but only a structure. so, it doesn't perform any action, and we cannot calculate a duration on it...
i think you wanted to ask for fstream methods compared with C file handling functions (fopen() , fclose() , fread() , fwrite() , fprintf() , fscanf() , ...)
insn't it ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
yes TOX u r right. which is faster fstream methods or C file handling functions................
lokiz
|
|
|
|
|
C io library is faster. But if you want really fast IO, you should better use directly Windows API
My programming blahblahblah blog. If you ever find anything useful here, please let me know to remove it.
|
|
|
|
|
You're asking the wrong question. FILE is C, fstream is C++. You should use C++ if your app is in C++, even if it takes a microsecond longer. Reasons - extensibility and ability to write good code.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I would like to write some code to compare the files within a directory with a 2nd directory and see which files are either not in the 2nd dir or have been changed. The aim of which is to basically duplicate the contents of a directory to another but only changing what is essential, as I will be sending the files over the internet.
Sorry, I know that wasn't very clear, but hopefully someone will understand what I want to find out!
Thanks in advance,
-Caolan
|
|
|
|
|
I am not sure why I am getting error in displaying the output. I want output such that when I enter a string aaaabaaba... for "aaa" it shud give output 0 and "aba" it should give output 1. I am not sure where the error is??? Please help thanks is advance.
#include<iostream.h>
#include<stdio.h>
#include<string.h>
#include<windows.h>
char* in;
void main()
{
cout << "Enter your string here \n";
cin>>in;
while(*in != ' ') //it crashes here
{
if(strncmp(in, "aaa", 3)==0)
cout << "0";
if(strncmp(in, "aba", 3)==0)
cout << "1";
in+=3;
}
}
A
|
|
|
|
|
ashok123 wrote: char* in;
This sets aside the memory to store an address, but it does not actually create a block of memory to store your string to. You have a pointer, but it's not pointing to anything.
ashok123 wrote: while(*in != ' ') //it crashes here
This code is wrong on a number of levels. First of all, it requires that the string have a space in it. Secondly, because you step by three further down, it assumes that the string will be either a space, or characters in a multiple of three, and then a space. The easiest way to solve all of this is to use std::string instead of a char *, and then use std::string's functions to check the contents of the string.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks Chris...
|
|
|
|
|
Hi friends
how copy my *.* files
target folder or other place please tell me copy code for C++
|
|
|
|
|
FindFirstFile and FindNextFile can be used to find the files, and CopyFile can be used to copy them.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi. I use RemoveAt() to remove objects from a list every time a given object attribute reach a certain value. The problem is that the objects are reaching the point faster than RemoveAt() can remove them from list, so there's a huge queue growing. Anybody knows how I could fix it?
CaCaPe
|
|
|
|
|
Code ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi How REad with C++ HDD Serial number ?
Please Help me
|
|
|
|
|
Someone can answer how can I find the calculus that the windows make to adjust the screen resolution?
Can be a link to a tutorial or something like this.
|
|
|
|
|
I don't understand the question ? Are you asking for the code to change the screen resolution yourself, or what ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
ok, I want to know is, why when I choose the screen resolution 1024x768
the values are these? Why not 1024x128 or 1024x963 or 1358x768?
Why these numbes? why 1024x768, 800x600, 1280x1024. What is the base for the definition of these numbers?
|
|
|
|
|
Screen Resolution means the number of pixels available on the monitor. You can think of a computer screen as a grid that is divided into a whole bunch of little squares. Each of these squares, or pixels, can be a different color, or black.
Resolution is the size of this grid of pixels. 1024x768 means that the screen is a 1024 by 768 grid of pixels. If the resolution is set to bigger numbers, say 1600 by 1200, each individual pixel will be smaller, and so the display is sharper and clearer.
The reason screen resolutions are not arbitrary numbers like 1358x768 is that most monitors display in a 4:3 ratio, in other words the width is 4/3 of the height. Because of the physical size of the screen, a ratio of 4:3 works. However, if the screen resolution was 1024 by 128, everything on the screen would be stretched. Instead of being little squares, the pixels would be little rectangles, and the display would look weird and distorted.
|
|
|
|
|
Ben, thanks a lot. This is the answer that I was searching. I needed this cause I'm developing an app that needs to generate little images based on screen resolution.
Thanks a lot for you.
|
|
|
|
|
hi every one this is for the first time i am logged to this web site and i am a newbe to programming world and facing problems to implement simple programs
can u tell me with source code how to implement
--- binary serach program
--- finding out a plaindrome
---- what is fibonacii series program
and sorting algorithms like bubble sort and selection sort
|
|
|
|
|
gunwinder wrote: --- binary serach program
you meant binary search, didn't you ?
google[^]
gunwinder wrote: --- finding out a plaindrome
you meant palindrom, didn't you ?
google again[^] have some answers for you
gunwinder wrote: ---- what is fibonacii series program
you mean fibonacci, didn't you ?
guess what ? google[^] have the answer
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
How to detect if the keyboard is connected or not.
i am using win98 and XP.
|
|
|
|
|
How can I initialize elements of arrays along with its dynamic creation?
For eg:
char ch(0);
This will initialize the ch with zero.
But the following is not possible.
char* ar = new char[20](0);
Is there any method to obtain the intended result?
Thanks!
- NS -
|
|
|
|
|
|
NS17 wrote: char* ar = new char[20](0);
Is there any method to obtain the intended result?
what about this?
char* ar = new char[20];
memset(ar,'0',20);
|
|
|
|