Maximus Posted March 25, 2012 Report Share Posted March 25, 2012 Salut, am gasit acest cod pe net#include "stdafx.h"#include <stdio.h>#include <gd.h>#include <gdfontg.h>int main(int argc, char *argv[]) { gdImagePtr img; FILE *fp = {0}; int width, white, black; width = white = black = 0; if(argc != 3) { fprintf(stderr, "Usage: pngtxt image.png 'Hello world.. !'\n"); return 1; } fp = fopen(argv[1], "wb"); if(fp == NULL) { fprintf(stderr, "Error - fopen(%s)\n", argv[1]); return 1; } width = strlen(argv[2]); img = gdImageCreate(width * 10, 20); white = gdImageColorAllocate(img, 255, 255, 255); black = gdImageColorAllocate(img, 0, 0, 0); gdImageString(img, gdFontGiant, 2, 1, argv[2], black); gdImagePng(img, fp); fclose(fp); gdImageDestroy(img); return 0;}Cand compilez, imi daError 3 error C2664: 'gdImageString' : cannot convert parameter 5 from 'char *' to 'unsigned char *' c:\users\maximus\documents\visual studio 2010\projects\text2pic\text2pic\text2pic.cpp 31 1 text2picError 2 error C3861: 'strlen': identifier not found c:\users\maximus\documents\visual studio 2010\projects\text2pic\text2pic\text2pic.cpp 24 1 text2pic 5 IntelliSense: argument of type "char *" is incompatible with parameter of type "unsigned char *" c:\users\maximus\documents\visual studio 2010\projects\text2pic\text2pic\text2pic.cpp 31 40 text2pic 4 IntelliSense: identifier "strlen" is undefined c:\users\maximus\documents\visual studio 2010\projects\text2pic\text2pic\text2pic.cpp 24 10 text2picWarning 1 warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. c:\users\maximus\documents\visual studio 2010\projects\text2pic\text2pic\text2pic.cpp 18 1 text2picMa poate ajuta cineva? Raman recunoscator.Multumesc Quote Link to comment Share on other sites More sharing options...
noVaLue Posted March 25, 2012 Report Share Posted March 25, 2012 In loc de #include <stdio.h> pune #include <iostream>Eu nu am acele headere, deci nu pot sa-ti spun... Quote Link to comment Share on other sites More sharing options...
nedo Posted March 26, 2012 Report Share Posted March 26, 2012 De fapt, ala nu se compileaza cu c++ ci cu cAla e cod de c. Compileaza-l cu gcc in loc de g++ si ar trebui sa functioneze fara probleme. Quote Link to comment Share on other sites More sharing options...
phreak Posted March 26, 2012 Report Share Posted March 26, 2012 De fapt, ala nu se compileaza cu c++ ci cu cAla e cod de c. Compileaza-l cu gcc in loc de g++ si ar trebui sa functioneze fara probleme.Fii mai atent, foloseste visual studio.Cat despre erorile tale.. http://msdn.microsoft.com/en-us/library/78zh94ax(v=vs.100).aspxhttp://www.learncpp.com/cpp-tutorial/44-type-conversion-and-casting/http://msdn.microsoft.com/en-us/library/yeby3zcb(v=vs.100).aspx Quote Link to comment Share on other sites More sharing options...
Maximus Posted March 26, 2012 Author Report Share Posted March 26, 2012 Multumesc tuturor. Am reusit. Quote Link to comment Share on other sites More sharing options...