Seite 41 von 340 ErsteErste ... 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 91 141 ... LetzteLetzte
Zeige Ergebnis 1.201 bis 1.230 von 10174

C/C++ Programming Help Thread

This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Zitat von CtrlAltDeleteDie Makefile: Code: TARGET = Select Square OBJS = main.o YOURLIBS= INCDIR = CFLAGS = -G4 -Wall -O2 ...

  
  1. #1201
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von CtrlAltDeleteDie
    Makefile:

    Code:
    TARGET = Select Square
    OBJS = main.o
    YOURLIBS=
    
    INCDIR =
    CFLAGS = -G4 -Wall -O2
    CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
    ASFLAGS = $(CFLAGS)
    
    LIBDIR =
    LDFLAGS =
    STDLIBS= -losl -lpng -lz \
    		-lpspsdk -lpspctrl -lpspumd -lpsprtc -lpsppower -lpspgu -lpspaudiolib -lpspaudio -lm
    LIBS=$(STDLIBS)$(YOURLIBS)
    
    EXTRA_TARGETS = EBOOT.PBP
    PSP_EBOOT_TITLE = SelectPSP
    
    PSPSDK=$(shell psp-config --pspsdk-path)
    include $(PSPSDK)/lib/build.mak
    Your target can only be one word. Change it to:

    Code:
    TARGET = SelectSquare



    Check out my homebrew & C tutorials at http://insomniac.0x89.org/
    Coder formerly known as Insomniac197

    tshirtz: what is irshell ??
    Atarian_: it's where people who work for the IRS go when they die

  2. #1202
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Spoiler for old post:
    Zitat Zitat von Lukeson
    Strings

    Hi, I'm having troubles with strings recieved via TCP; I'm getting a string "[list of artists]" from a simple TCP echo server (you don't need to view this, all it does is recieve a command (string) from the client and answer "[list of artists]".

    Spoiler for server code:
    Code:
        for (;;) {
            len = sizeof(client);
            fd = accept(sock, (struct sockaddr*)&client, &len);
            if (fd < 0)
                error_exit("Error while accepting\n");
    		
    		printf("Incoming Client: %s\n", inet_ntoa(client.sin_addr));
    
    		if((rc = recv(fd,commandbuffer,RCVCOMMSIZE,0)) < 0)
    			printf("Error while recieving the command; error-code: %d\n",WSAGetLastError());
    		if(rc==0)
    			printf("Client has closed the connection...\n");
    
    		commandbuffer[rc]='\0';
    		printf("Client command: %s\n",commandbuffer);
    
    		printf("Sending answer...\n");
    		sprintf(answer,"[list of artists]");
    		rc=send(fd,answer,strlen(answer),0);
    
    	printf("Closing connection\n\n\n");
            closesocket(fd);


    More relevant code; How the client recieves the string from the server:

    Code:
        command = "get_artists";
        command_len = strlen(command);
    
    	if (send(socket, command, command_len, 0) != command_len) {
            printf("send() sent a different length of bytes than expected!\n");
    		return;
    	}
    	printf("sending command get_artists...\n");
    
    	printf("recieving...\n");
    	while(rc!=SOCKET_ERROR)
    	{
    		printf("Recieving package %d\n", i);
    		rc = recv(socket,buf,256,0);
    		buf[rc]='\0';
    		if(rc==0)
    		{
    			printf("Server has closed the connnection\n");
    			break;
    		}
    		if(rc==SOCKET_ERROR)
    		{
    			printf("Error: recv, error-code: %s\n",strerror(errno));
    			break;
    		}
    		strcat(recivedMessage, " - ");
    		strcat(recivedMessage, buf);
    		printf("buf: %s\n", buf);
    		printf("recivedMessage: %s\n", recivedMessage);
    		i++;
    	}
    	printf("\n\nget_artists returned: %s\n", recivedMessage);
    IMHO seems fine, but look what he does:

    Could it be that he prints buf, which as an array has the size of 265, completely, the whole 256 chars?
    -= Double Post =-
    PS: Damn that psp is dirty!
    I found the source of the problem;

    recivedMessage was declared[4096] but not initialized.

    Thanks to everyone who racked their brains...

    Strings and variable length

    Hi,
    how can I create strings of variable length in C(non++)? I have a viariable that will be filled in a loop; I can't say when this loop will stop, I don't know how long the string will be. Do I have to use realloc(string, sizeof(string)+sizeof(add edString)) each time in the loop? Or is there a better way?
    Geändert von Lukeson (10-10-2006 um 07:26 AM Uhr) Grund: Automerged Doublepost

  3. #1203
    QJ Gamer Green
    Points: 25.223, Level: 95
    Level completed: 88%, Points required for next Level: 127
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Beiträge
    4.289
    Points
    25.223
    Level
    95
    Downloads
    0
    Uploads
    0

    Standard

    char string[variable]; ?
    I can't remember, its been so long since I've programmed, and now I'm taking a Java class in school...
    QJ loads way 2 slow & the theme is ugly as hell, gone are the glory days

  4. #1204
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    char string[variable];
    And what if the string gets longer than <variable>?
    -= Double Post =-
    I'd actually even be happy if someone could confirm that the method I thought of (using realloc each time in the loop) actually is a method and not utter bull****
    Geändert von Lukeson (10-10-2006 um 07:43 AM Uhr) Grund: Automerged Doublepost

  5. #1205
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Standard

    malloc & realloc.

    Check out my homebrew & C tutorials at http://insomniac.0x89.org/
    Coder formerly known as Insomniac197

    tshirtz: what is irshell ??
    Atarian_: it's where people who work for the IRS go when they die

  6. #1206
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    You really want to avoid reallocating memory at runtime on a console. Just make the buffer a fixed size (eg 4096) and ensure that the message sent is no longer then that.

    Your method of realloc would work but might be slow depending on the implementation of the function.

    Another method would be to send the size of the message of first then the actual message.

  7. #1207
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Just make the buffer a fixed size (eg 4096) and ensure that the message sent is no longer then that.
    I'm retrieving a list of artists from winamp, always different and surely larger than 4096 at many PCs
    Your method of realloc would work but might be slow depending on the implementation of the function.
    If it makes the console run slow I think I'll go with the other solution you mentioned. Can you actually send and recieve X bytes or is there a limit? Like i need to send a list of 411 Artist (~6165bytes) at once...
    -= Double Post =-
    Converting numbers to char-arrays
    I get a number from sizeof and need to save it in an array of chars (char length[8]). How do you do that?
    Geändert von Lukeson (10-10-2006 um 10:30 AM Uhr) Grund: Automerged Doublepost

  8. #1208
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    Number to char arrays, use sprintf.

    Yes there is a limit to how much data you can send in a packet on the network. I can't remember off hand what it is though.

  9. #1209
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Lukeson
    Converting numbers to char-arrays
    I get a number from sizeof and need to save it in an array of chars (char length[8]). How do you do that?
    You'd have to use the itoa function.
    Or sprintf if you want.


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  10. #1210
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Thanks guys
    -= Double Post =-
    Hmmm but how do I convert a char to an int? I tried

    artist_list_length = (int)artist_list_length_c ;

    but it fills artist_list_length with 16thousand-whatever-the-unsigned-int-maximum is...
    Geändert von Lukeson (10-10-2006 um 11:07 AM Uhr) Grund: Automerged Doublepost

  11. #1211
    Developer
    Points: 7.577, Level: 58
    Level completed: 14%, Points required for next Level: 173
    Overall activity: 0%

    Registriert seit
    Mar 2006
    Beiträge
    1.026
    Points
    7.577
    Level
    58
    Downloads
    0
    Uploads
    0

    Check out my homebrew & C tutorials at http://insomniac.0x89.org/
    Coder formerly known as Insomniac197

    tshirtz: what is irshell ??
    Atarian_: it's where people who work for the IRS go when they die

  12. #1212
    QJ Gamer Silver
    Points: 10.263, Level: 67
    Level completed: 54%, Points required for next Level: 187
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Ort
    UK
    Beiträge
    2.326
    Points
    10.263
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    atoi()

  13. #1213
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Yay, everything works fine now, thanks again!

    PS: This is the first time I'm doing something in C, so please be kind to me
    -= Double Post =-
    i have another noob-question: I got the following code

    Code:
    void get_artists(int socket, char * recivedMessage)
    {
    	buf[recieved_size] = recieve_message_of_variable_length();
    	recivedMessage = (char)malloc(recieved_size);
    }
    
    char buffer;
    
    get_artists(socket, buffer);
    to get the artists from winamp. The part with malloc freezes my PSP. How else can I make buffer the right size?
    Geändert von Lukeson (10-10-2006 um 12:12 PM Uhr) Grund: Automerged Doublepost

  14. #1214
    Developer
    Points: 5.359, Level: 47
    Level completed: 5%, Points required for next Level: 191
    Overall activity: 0%

    Registriert seit
    Feb 2006
    Ort
    Norway
    Beiträge
    384
    Points
    5.359
    Level
    47
    Downloads
    0
    Uploads
    0

    Standard

    I've been trying to get the debug text to work with a prx for devhook.

    I first tried using the normal one from pspdebug.h (pspDebugScreenPrintf)
    but that gave me these errors
    Spoiler for errors:

    /usr/local/pspdev/psp/sdk/lib/libpspdebug.a(scr_printf. o): In function `pspDebug
    ScreenInit':
    /tmp/pspdev/pspsdk/src/debug/scr_printf.c:52: undefined reference to `sceGeEdram
    GetAddr'
    /usr/local/pspdev/psp/sdk/lib/libpspdebug.a(scr_printf. o): In function `pspDebug
    ScreenPrintf':
    /tmp/pspdev/pspsdk/src/debug/scr_printf.c:168: undefined reference to `vsnprintf
    '
    collect2: ld returned 1 exit status


    I also tried without defining which I thought maybe could possibly workbecouse I had -fno-builtin-printf which I have in CFLAGS. I didn't get any errors then but no text appeared..

    Do I have to do something else to get it working in prx'es? Or is there some other simple text function that exists that works?


  15. #1215
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    waterbottle - Sorry, i havent any experience with PRX printing routines... Or anything PRX that matter...

    Lukeson - 'malloc' doesnt just stop working and makes it crash. Either you havent free'd the current memory in recieveMessage, you're trying to allocate memory to something whose memory already has been allocated or all else fails, something you're calling before is causing it to crash -- meaning maybe a call to malloc before yours corrupts the stack, or something of the sort... All i know for sure is malloc doesnt just stop working for no reason...

    Best of luck with your problem, wish i could help more...

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  16. #1216
    likes kittens....awww....
    Points: 6.975, Level: 55
    Level completed: 13%, Points required for next Level: 175
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Detroit
    Beiträge
    628
    Points
    6.975
    Level
    55
    Downloads
    0
    Uploads
    0

    Standard

    Can vars have double quotes in them?
    For example:
    Code:
    short inches = "Inches";

  17. #1217
    words are stones in my <3
    Points: 35.274, Level: 100
    Level completed: 0%, Points required for next Level: 0
    Overall activity: 0%

    Registriert seit
    Jul 2005
    Ort
    Spokane
    Beiträge
    5.008
    Points
    35.274
    Level
    100
    My Mood
    Lonely
    Downloads
    1
    Uploads
    0

    Standard

    psp - character arrays, yes. Others, not so sure but you CAN add the ASCII value together and have hte same effect I suppose, but after each char you need an + operator...

    int string = 'h'+'e'+'l'+'l'+'o'; // add ASCII values together, not so useful
    char string[] = "hello"; // auto sizes array
    char string[6] = "hello"; // make room for '\0' char

    ...at what speed must I live.. to be able to see you again?...

    Projects

    You can support my Open World 3D RPG for PSP by voting for it here


  18. #1218
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Me
    i have another noob-question: I got the following code

    Code:
    void get_artists(int socket, char * recivedMessage)
    {
    	recieved_size = recieve_message_size();
    	buf[recieved_size] = recieve_message_of_variable_length();
    	recivedMessage = (char)malloc(recieved_size);
    }
    
    char buffer;
    
    get_artists(socket, buffer);
    to get the artists from winamp. The part with malloc freezes my PSP. How else can I make buffer the right size?
    The correct version should be:

    Code:
    void get_artists(int socket, char * recivedMessage)
    {
    	recieved_size = recieve_message_size();
    	buf[recieved_size] = recieve_message_of_variable_length();
    	recivedMessage = (char*)malloc(recieved_size);
    	printf("recievedMessage-size: %d\n", sizeof(recivedMessage));
    	return;
    }
    
    char * buffer;
    
    get_artists(socket, buffer);
    printf("get_artists returned: %s", buffer);
    However this version freezes after printing "recievedMessage-size: 15" and doesn't print "get_artists returned: message".

    Does anyone have an explanation for this?
    -= Double Post =-
    Or, if not an explanation, probably even a better solution for getting a string of variable length from a function
    Geändert von Lukeson (10-11-2006 um 04:36 AM Uhr) Grund: Automerged Doublepost

  19. #1219
    Developer
    Points: 4.872, Level: 44
    Level completed: 61%, Points required for next Level: 78
    Overall activity: 0%

    Registriert seit
    Jun 2006
    Beiträge
    82
    Points
    4.872
    Level
    44
    Downloads
    0
    Uploads
    0

    Standard

    Code:
    void get_artists(int socket, char * recivedMessage)
    {
    	buf[recieved_size] = recieve_message_of_variable_length();
    	
    }
    you assign the return value from receive_message_of_variab le_length() to the array, not the variable recieved_size
    Code:
    	recivedMessage = (char*)malloc(recieved_size);
    
    }
    Since recieved_size is not assign a value, it contains random value. You're allocation a random number of memory.

    Code:
    	printf("recievedMessage-size: %d\n", sizeof(recivedMessage));
    	return;
    }
    Memory allocated, but you didn't assign any value to it. You're trying to print some random value.

    Two more things:
    1. sizeof(recivedMessage), it returns the size of a char*, becoz recivedMessage is a char*. It won't return the message size.

    2. If you don't use the pointer correctly, it's always result in a crash.

  20. #1220
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    correct;)

  21. #1221
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Ahh, sorry, what I wrote up there is simplified code just to explain the problem, here's the real deal:

    Code:
    void get_artists(int socket, char * recivedMessage)
    {
    	char *command;
    	int command_len;
    	char artist_list_length_c[8];
    	int artist_list_length;
    	long rc;
    
    	command = "get_artists";
    	command_len = strlen(command);
    
    	if (send(socket, command, command_len, 0) != command_len) {
            printf("send() sent a different length of bytes than expected!\n");		// needs real exceptionhandling
    		return;
    	}
    	printf("\n\nsending command get_artists...\n");
    
    
    	if((rc = recv(socket, artist_list_length_c, 8,0)) < 0) {
    		printf("Error while recieving the artist-list-length; error-code: %s\n",strerror(errno));
    		return;
    	}
    	if(rc==0) {
    		printf("Client has closed the connection before sending the artist-list-length\n");
    		return;
    	}
    
    	printf("Recieving artist-list-length\n");
    	artist_list_length_c[rc]='\0';
    	artist_list_length = atoi(artist_list_length_c);
    	printf("Artistlist length: %d\n", artist_list_length);
    	artist_list_length++;
    	char buf[artist_list_length];
    
    	recivedMessage = (char*)malloc(artist_list_length);
    
    	printf("recieving artist-list...\n");
    	rc = recv(socket,buf,artist_list_length,0);
    	if(rc==0)
    	{
    		printf("Server has closed the connnection before sending the artist-list\n");
    		return;
    	}
    	if(rc==SOCKET_ERROR)
    	{
    		printf("Error: recv, error-code: %s\n",strerror(errno));
    		return;
    	}
    	buf[rc]='\0';
    	strcpy(recivedMessage, buf);
    	printf("recivedMessage length: %d\n", strlen(recivedMessage));
    	printf("buf: %s\n", buf);
    
    	return;
    }
    In another function that is called in main():

    Code:
    char* artist_list;
    
    	get_artists(sock, artist_list);
    	printf("\n\nget_artists returned: %s\n", artist_list);
    Sorry for the confusion
    -= Double Post =-
    Hoever it works using malloc after the initialization and the reallocating it... .
    Geändert von Lukeson (10-11-2006 um 05:36 AM Uhr) Grund: Automerged Doublepost

  22. #1222
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    i have some problem when you make array's and let the user put in the value
    how can you "+" them
    for exemple
    int repeat()
    {

    int totaal , scores[5];
    totaal=?????????????????
    cout<<"geef de scores van de toetsen\n";
    cin>>scores[1]>>scores[2]>>scores[3]>>scores[4]>>scores[5];
    cout<<"de gemmidelde score voor deze test is "<<totaal /(sizeof(scores)/sizeof(int));
    note two :
    how cane you let the user put in more numbers for example
    the user wants to put in 20 numbers expect 5
    int repeat()
    {

    int totaal , scores[?????];
    totaal=??????????;
    cout<<"geef de scores van de toetsen\n";
    cin>>??????????;
    cout<<"de gemmidelde score voor deze test is "<<totaal /(sizeof(scores)/sizeof(int));

    i use cout , but dont wory this is something for psp;)

  23. #1223
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    how can you "+" them
    Errm, what do you mean?
    totaal = scores[1] + scores[2] + scores[3] + scores[4] + scores[5];
    ?
    how cane you let the user put in more numbers
    Example:

    Code:
    int n=0, max=5, z,i;
    int *scores=NULL;
    scores = (int *)calloc(max, sizeof(int));
    
    printf("enter scores; end with 0\n");
    
    while(1)
    {
    	printf("Enter Score #%d: ", n+1);
    	scanf("%d", &z);
    	if(z==0)
    		break;
    	if(n >= max) {
    		max += max;
    		scores = (int *)realloc(scores,max*sizeof(int));
    	}
    	scores[n++] = z;
    }
    
    printf("The following scores have been entered ->\n\n");
    for(i = 0; i < n; i++)
    	printf("%d ", scores[i]);
    printf("\n");
    free(scores);

  24. #1224
    Heroes never die
    Points: 8.645, Level: 62
    Level completed: 65%, Points required for next Level: 105
    Overall activity: 0%

    Registriert seit
    Aug 2006
    Ort
    ...........
    Beiträge
    1.323
    Points
    8.645
    Level
    62
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Lukeson
    Errm, what do you mean?
    totaal = scores[1] + scores[2] + scores[3] + scores[4] + scores[5];
    ?
    lol , ofcourse i know that:ROFL:
    but 1) it's a bi work
    2) you answered that in question 2 , thnxxx

  25. #1225
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    Now I've got a question:

    if you open a file of let's say 200byte and you write 50bytes with fprintf, will it just replace the first 50 bytes an leave the rest as it it (I guess so) or will it replace the file with a new one of 50 bytes? And if you write 300bytes into that file, will there be problems, or will he just create a file of 300bytes then?

    Thanks, Luke

    PS: What the hell does [WiP] actually mean?
    PPS: How do I remove a file? remove(filename)?
    Geändert von Lukeson (10-11-2006 um 08:28 AM Uhr)

  26. #1226
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    Zitat Zitat von Lukeson
    Now I've got a question:

    if you open a file of let's say 200byte and you write 50bytes with fprintf, will it just replace the first 50 bytes an leave the rest as it it (I guess so) or will it replace the file with a new one of 50 bytes? And if you write 300bytes into that file, will there be problems, or will he just create a file of 300bytes then?

    Thanks, Luke

    PS: What the hell does [WiP] actually mean?
    PPS: How do I remove a file? remove(filename)?
    That depends whether you choose to truncate the file when you open it. I would suggest reading some about the fopen function.

    WiP = Work in Progress ;)

    Not sure if the remove function actually works, but you can use the sdk function sceIoRemove(filepath).


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  27. #1227
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    An answer! Thank you!

    PS: How do you know so much about the SDK? The only documentation I found sucks and the samples don't include AFAIK no fileIO examples...

  28. #1228
    AKA Homer
    Points: 12.596, Level: 73
    Level completed: 37%, Points required for next Level: 254
    Overall activity: 0%

    Registriert seit
    Jan 2006
    Ort
    Sweden
    Beiträge
    1.779
    Points
    12.596
    Level
    73
    Downloads
    0
    Uploads
    0

    Standard

    The includes (.h) in /usr/local/pspdev/psp/sdk/include have some documentation, like right before the functions it says what it does etc.


    Click Here if you want a Winamp Currently Playing Userbar like the one above.

  29. #1229
    QJ Gamer Blue
    Points: 4.511, Level: 42
    Level completed: 81%, Points required for next Level: 39
    Overall activity: 0%

    Registriert seit
    Sep 2006
    Ort
    Germany
    Beiträge
    216
    Points
    4.511
    Level
    42
    Downloads
    0
    Uploads
    0

    Standard

    i c...

  30. #1230
    Developer
    Points: 10.075, Level: 67
    Level completed: 7%, Points required for next Level: 375
    Overall activity: 0%

    Registriert seit
    Sep 2005
    Ort
    Sweden
    Beiträge
    941
    Points
    10.075
    Level
    67
    Downloads
    0
    Uploads
    0

    Standard

    All the documentation are stored in usr/local/pspdev/psp/sdk/doc/html. Then just open main.html. I get the feeling that must stuff is documented there.


 

Tags for this Thread

Forumregeln

  • Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
  • Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
  • Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
  • Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.
  •  





Alle Zeitangaben in WEZ -8. Es ist jetzt 09:28 PM Uhr.

Use of this Web site constitutes acceptance of the TERMS & CONDITIONS and PRIVACY POLICY
Copyright © , Caputo Media, LLC. All Rights Reserved. Cluster .