Search found 46 matches

by Fresh
Fri Apr 16, 2004 10:14 am
Forum: C++
Topic: How do u check for eoln in C++?
Replies: 3
Views: 2458

A help

Hope this help :wink:

[cpp]

#include <fstream.h>

void main()
{
char str[1024];

ifstream in("data.txt");

if (in.is_open())
{
while (in.getline(str, sizeof(str)))
{
// the process is here
}

in.close();
}
}

[/cpp]
by Fresh
Wed Apr 14, 2004 6:40 am
Forum: C++
Topic: Copy unsigned char* to int Variable
Replies: 1
Views: 1562

Copy unsigned char* to int Variable

Hi, Help plz, attached is my code. Is it a right way to copy unsigned char* to int variable? Thanks in advance... -fresh :oops: [cpp] #include <string.h> #include <stdio.h> #include <stdlib.h> void main() { int len; char tmp[1024*8]; unsigned char *ptr, buf[1024*8]; char *s1 = "ACM INTERNATIONAL COL...
by Fresh
Thu Jan 08, 2004 4:26 am
Forum: C
Topic: malloc
Replies: 17
Views: 8069

Free...

Hi, so many ways to alloc 2d array. But how to free it? [cpp] #include <stdio.h> #include <stdlib.h> void main() { char **x = (char**)malloc(5); for (int i=0; i<5; i++) x = (char*)malloc(20); for (i = 0; i < 5; i++) sprintf(x , "string#%d", i + 1); for (i = 0; i < 5; i++) printf("%s\n", x ); for (i ...
by Fresh
Wed Dec 03, 2003 4:41 am
Forum: C++
Topic: Delete Bytes From A Text File
Replies: 3
Views: 1970

...

I don't understand. Can I get the full code? :oops: What happen to the last bytes of the file... have they been deleted?

-novice
by Fresh
Wed Nov 19, 2003 9:44 am
Forum: C++
Topic: Delete Bytes From A Text File
Replies: 3
Views: 1970

...

Help!
by Fresh
Mon Nov 17, 2003 6:54 am
Forum: C++
Topic: Delete Bytes From A Text File
Replies: 3
Views: 1970

Delete Bytes From A Text File

Hi, I created a text file. Write 5 byes('ABCDE') to the file. After closing the file... I want to delete its last character('E') by reading all file contents and recreating a new one with same filename. Is it possible to do this in just one time 'fopen()'? Facing with problems when the file size is ...
by Fresh
Tue Jul 01, 2003 3:56 am
Forum: C++
Topic: Convert Number
Replies: 2
Views: 1750

...

Thanks....

- novice :wink:
by Fresh
Wed Jun 18, 2003 10:12 am
Forum: C++
Topic: Convert Number
Replies: 2
Views: 1750

Convert Number

Hi, I'm looking for the fastest algorithm to convert an unsigned int to string in format x,x,x,x,x. Thanks... void convert(unsigned int, char *buf) { // need help .... .... .... } void main() { char buf[1024]; unsigned int x = 2123456; convert(x, buf); printf("%s\n", buf); // buf = 2,123,456 } - nov...
by Fresh
Fri Dec 20, 2002 5:41 am
Forum: Other words
Topic: acm solve sites
Replies: 51
Views: 25207

...

I think that solutions to problems should not be accessible, at least not for many problems. If there are solutions to many problems, it would be easy for someone to send them all to online judge and appear on front page of the ranklist. Every person who don't cheat and work for months/years to rea...
by Fresh
Wed Dec 11, 2002 9:17 am
Forum: Other words
Topic: About new incoming features
Replies: 47
Views: 27512

...

fpnc wrote:Right now everything will be hold as is - Real Time System Status shows numbers unless you use "T" option, and the other ranklists will show the name if they show it now. It may be changed in the future, however.
How?

-novice :roll:
by Fresh
Mon Dec 02, 2002 3:33 pm
Forum: C++
Topic: Grow Array Size
Replies: 13
Views: 4338

...

Hi, Another simple question, what is the different (faster) between using pointer and set element index, as below? I dont know... :-? [cpp] char str[100] = "abcdefghijklmnopqrstuvwxyz"; for (int i=0; str ; i++) printf("%c", str ); [/cpp] [cpp] char *ptr, str[100] = "abcdefghijklmnopqrstuvwxyz"; ptr ...
by Fresh
Wed Nov 27, 2002 10:07 am
Forum: C++
Topic: Bigint
Replies: 37
Views: 16529

...

They do, look at .\contrib\mpi_cpp\mpicpp.h

-novice :wink:
by Fresh
Wed Nov 27, 2002 3:34 am
Forum: C++
Topic: Bigint
Replies: 37
Views: 16529

...

by Fresh
Tue Nov 26, 2002 8:51 am
Forum: C++
Topic: Grow Array Size
Replies: 13
Views: 4338

...

I don't want to break the rule. The code below convert my BigInteger to a base (2 - 64) string. The method#1 might faster than the #2 but ... any comment? Method#1 [cpp] static const char *BASE_DIGIT = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz+/"; char *BigInteger::toString(con...
by Fresh
Tue Nov 26, 2002 4:11 am
Forum: C++
Topic: Grow Array Size
Replies: 13
Views: 4338

...

Hi, Another question about pointer. My simple code as below, why ptr still hold the value after b was freed? What happen to elements[0-3]? Did they completely freed? [cpp] char *GetString() { char *ptr, *b = new char[10]; b[4] = 'F'; b[5] = 'r'; b[6] = 'e'; b[7] = 's'; b[8] = 'h'; b[9] = '\0'; ptr =...

Go to advanced search