Hey,
Can anybody help me write a function to open files (aka same thing as fopen) but without using any hidden libraries (aka fclose.c... and so on) and without using the cheap microsoft .net stuff.... just the simplest way of writing it and still be effiecient.... thanks
by the way... I looked at the stuff from fopen and have no idea what most of it is suppost to do lol...
P.S. this is PURLY PRACTISE...
User Profile
Collapse
-
Challenge - Manually opening a file....
-
*SOLUTION*
Alright i was thinking about this for a long time and figured out what i can do.... here is what i did....
Code:#define Number 8 typedef char* pChar; // converts a string into a pChar pChar StrpChar (string InStr) { return _strdup(InStr.c_str()); } // Converts integer into a pChar pChar StrInt (__int64 InNum) {[INDENT] ostringstream[/]
-
Small problems formatting maps (<map>)
Hey,
consider the following chunk of code
[CODE]
#define CONSTANT 5
void func (const char *Code)
{
map <pChar, pChar> Codes;
Codes["A100"] = "SOMETHING\ n";
Codes["A101"] = "ANOTHER SOMETHING", CONSTANT, "\n";
if (Codes.find(Cod e) != Codes.end())
fprintf_s (stderr, CodesCode:); else
-
solved!!!
make key optional by issuing it a defauly parameter then checking to see if its NULL or not... if yes then read it if its NULL then ignore and more on....Leave a comment:
-
strcmp multiparam second opinion
Greetz,
i just need a second hand opinion from other people....
say i have a function [-Encrypt Key] but the Key part is optional....
the way i have it layed out now is
Code:if (strcmp (argv[i+1], "-InFile /*or another argument*/) == 0)
-
Pointing to specific parameter....
Any quick way to point to a specific parameter instead of by its name.... example
void func (char nameA, char nameB)
any way i can refer to them direct aka like param 1, param2, or first, second, etc... -
# of parameters
How can i (inside a function) read how many parameters were passed to it....
(if your saying thats easy you should know when writing the functions i suggest you look into --> va_arg, va_end, va_start <-- inside <stdarg.h>)
thanks, -
Parameter overdrive.....
Hey i have a rather wierd question....
say i have a function that compares strings that looks like the following when used in code:
Code:if ((StrComp (some char* here, another char* here)) [.......]
now i have a group of strings i want to compare and i dont want to write like... -
alright thanks, ive been actually thinking about it and yeah i kinda agree.... no point since cout will only use it....Leave a comment:
-
um alright well...
typedef unsigned char byte;
but of cource when i define a variable with byte it gives me characters rather than numbers for example:
------------------------------------------------------------
#include <iostream>
typedef unsigned char byte;
using std::cout;
main()
{
byte Value = 5;
cout << Value;
}...Leave a comment:
-
Simple typedef question......
Hey,
is it possible to typecast inside typedef, for example:
typedef char DEF
but instead of displaying definition as a character and NOT having to typecast later on (aka DEF something = 5; cout << (int)something; )
is there any way to typecast right at the beggining at the typedef stage....
thanks,
P.S any clever alternatives to this welcome..... as long... -
Well needing to know the format of the file kinda eliminates of what im really trying to do....
if you look at the Half life 2 gameinfo.txt and weapon scripts (well practically the whole game definition system) you would see that there is no format and everything is very random.....
here i found a wikipedia entry to help me but im still kinda unclear about this whole topic...
http://en.wikipedia.or g/w...Leave a comment:
-
Indexing .txt files in c++
Hello,
although this question has probebly been answered a bunch of times i couldent find the answer im looking for.... anyways what im trying to do is....
Say i want to create a c++ program to read something from a file but i want the file to be in the following format...
File.txt
----------------------------
"Data"
{
"Data1" "546"
...
No activity results to display
Show More
Leave a comment: