programming help c++

how can i read a png file from folder.

any help appreciated.

Google?

Oh I see, this is a cross-post.

forum.arduino.cc/index.php?topic=297438

Better not let the moderators spot it.

i need to read the name of png file from folder.

the path is ptuxiaki/dropbox/iftt/twitter.

i dont knwo how to write the code in c++

Here you go:

  1. Google

  2. Input/output with files - C++ Tutorials

riesens:
Here you go:

  1. Google

  2. Input/output with files - C++ Tutorials

is that use also for png file or only txt?

The fstream libraries can be used for any file type.

can u make a example how i chose the path where the files is, in my situation the png file is in workspace
ptuxiaki/dropbox/ittf/twitter

in the constructor you need to give both the directory and Filename in the argument string

ifstream myfile ("path/to/files/example.txt");

the file name in folder is greated when when my twitter account receive a tweet and i receive in from dropbox in png format.

the files names comes from twitter account=giannis and message=open. giannis_open.png

so i need to write code ifstream myfile (workspace/ptuxiaki/dropbox/iftt/twitter/giannis_open.png)

right?

yes

(assuming that you are executing the program in the parent directroy to workspace - otherwise you need to set the relativity of the path correct, i.e. use an absolute path)

Please I cannot found a CLEAR tutorial on how to program an atmel 328p (arduino uno for instance) in C.
It will be interesting programing it in C instead of the arduino IDE in order to have some calculus program running as fast as possible.
ASM is faster than C but too irksome to program.

How faster is a program written in pure C than a program written under the arduino IDE?
For instance, to find prime numbers, how faster will a C program compared to a program written under arduino-ide run?

I expect at least twice the speed, e.g. if 4 minutes are needed to generate a list of prime numbers, the same program written in C and burned in the at328p should take at most 2 minutes to generate the same list.

Thank you for sharing your knowledge !!

:slight_smile:

ps: my main field of expertise is mathematics (statistics) if help is required in this field you can send a message

NiceAntoine:
Please I cannot found a CLEAR tutorial on how to program an atmel 328p (arduino uno for instance) in C.
It will be interesting programing it in C instead of the arduino IDE

Seriously?

Are you aware that the Arduino IDE is just that: an IDE, not a language. It uses C/C++

However, if that is not hardcore enough for you, you can always use Atmel Studio 6.

BTW, try not to hijack someone else's thread for your own questions, specially with a totally unrelated problem.

the title of the tread: programming help C++
my question is about.....
Programming help in c++

shall I open a thread entitled "programming help in C++"? definitively NO.

The arduino Integrated Developpement Environement is based on C/C++ programming rules and syntax.

But I am interested in speed of execution, a "real" C program burned in a processor is expected (at least by me) to run faster than a program done under the arduino-IDE.

Arduino environement makes programming easy but that hides some complex features and the resulting compiled program runs slower than a program written in C (mo matters the IDE).
In the same way, a program written in ASM should be even faster than its C equivalent.

Yes Atmel studio is done to do that, however as me and the person who opened this thread have not find a way or a clear tutorial, we are asking for help.

Anyway, thank you for your (useless) answer.
Have a nice day.

NiceAntoine:
In the same way, a program written in ASM should be even faster than its C equivalent.

Hmmm.... not true. Unless you can write better code than the compiler can generate from the C/C++ code, they are the same speed, because both codes are turned into machine instructions. It is even possible to write worse and slower code in ASM if you are a lousy programmer.

Programming in ASM is not only about speed, as you suggest: it is about being better than the compiler, be it in speed, optimization, code or using mnemonics the compiler won't generate.

NiceAntoine:
Yes Atmel studio is done to do that, however as me and the person who opened this thread have not find a way or a clear tutorial, we are asking for help.

The person who opened the thread used a completely inadequate title for his thread. He wanted a specific help with opening PNG files, not general C++ programming help. He even posted in the wrong section of the forum. There is a special area for programming in these forums, and one error (his) doesn't justify another (yours).

NiceAntoine:
Anyway, thank you for your (useless) answer.

You're not as nice as your name suggests! :grinning: :grinning:

NiceAntoine:
Have a nice day.

Oh, I am having a great day! Even although it is Monday, all my code is compiling without even a warning! How grand is that! :smiley: :smiley: :smiley:

NiceAntoine:
the title of the tread: programming help C++
my question is about.....
Programming help in c++

Arduino environement makes programming easy but that hides some complex features and the resulting compiled program runs slower than a program written in C (mo matters the IDE).
In the same way, a program written in ASM should be even faster than its C equivalent.

Asserting facts not in evidence.

Other than the setup() and loop() function, the "IDE" adds no overhead. You may want to adjust some of the multitude of gcc options that the IDE hides from you, but that is a different story.

Feel free to use the AVR toolchain and ignore the IDE entirely.

Thank you for your usefull comments!

So I was wrong thinking that changing the programming language may easily speed the execution of the code.

However I used to do programs related to statistical image processing in C++ and in C#, the difference in speed between two equivalent implementations is absolutely clear.

I had the idea(apparently wrong) that coding directly in C will speed up noticeably time of calculations.
Thank you for the information, however as soon as I get some decent tuto on programming with atmel studio, I will test the speed by generating prime numbers.

This was my first post on the forum :smiley: , all of you have a nice day!!!!

NiceAntoine:
However I used to do programs related to statistical image processing in C++ and in C#, the difference in speed between two equivalent implementations is absolutely clear.

I'm guessing C++ was faster.

Why would you use a microcontroller, the purpose of which is primarily embedded control, to generate prime numbers?

Speed test.