-
anithmetic
which way is the better way ?
i get this error with this line
34 C:\.....cpp [Warning] NULL used in arithmetic
Code:
while(line[buf] != NULL){ cout << line[buf]; buf++; }
it still compiles but just gets stuck doing nothing. would
Code:
while(line[buf] != "" ){ cout << line[buf]; buf++; }
or
while(line[buf] != 0 ){ cout << line[buf]; buf++; }
be better ? or something else ? thank you.
-
What do you want to check? Whether line[buf] contains ANY string, or whether the string it contains is empty?
Code:
while(line[buf] != NULL){ cout << line[buf]; buf++; }
Checks whether it contains any string.
Code:
while(line[buf] != "" ){ cout << line[buf]; buf++; }
Wrong in both cases.
Code:
while(line[buf] != 0 ){ cout << line[buf]; buf++; }
Same as the first one.
-
Code:
while (!in.eof())
{
getline (in, line);
meta = line.find("meta");
if(meta >= 0)
{
cout << "\nmeta == " << fileline << "\n" << endl;
name = line.find("data");
buf = name + 12;
cout << "meta: ";
while(line[buf] != NULL){ cout << line[buf]; buf++; }
cout << endl;
both ? how about the end of the tag data ?
prog looks for "meta" tag data inside a file. reads data in to variable and puts that out to the screen. problem is finding end of tag data. there are several strings as far as i can tell. then more of the file. want to read all the strings in the right variable. thinking that this could be redone as a structure and then filled. i need to do some more reading on tags and see if i can find the one this file uses. then i should have some reference as to how long each string is.
figured out why it just sits there doing nothing. there was no "meta" tag in side the file. i opened the file with notepad. there were other tags in there. as i said i need to find the info on which tag this file uses. thank you for the reply and it helped me realize that i was missing the info i needed to do the program.
-
1. From where the variable fileline is accessed? (As i can't see through your whole code, anyways let i suppose it's initialized or set somewhere.)
2. Okay, let take a case.
e.g. Your line array contains: "My meta found a huge data"
When you first find meta, it should return 3 and within loop when you find data it should return 21, and you add 12 in it which makes buf as 33 and your string is of length less than 33.
-
You should check if the second find actually succeeds.
Furthermore, it is bad to use eof as loop control. There IS a faq about that on the site.
And finally, I have no idea what this piece is supposed to do:
Code:
while(line[buf] != NULL){ cout << line[buf]; buf++; }
-
i did not write the original program. i only tried to modify it to do what i wanted. thank you for the suggestions. i am going to read through the faq again. that line i thought reads in the tag line and puts it in the buffer and then increments the count. guess not. going to restart. first when i find the info on the wright tag then i will apply that.
-
We cannot see how "line" is declared.
And the...
line[buf] != NULL
...looks suspicious.
-
it is defined as a string. as i said i am going to start over with this project. i just needed something quick to check the tags.
[code ]
string line;
[/code]
-
TIFF Tag Reference, EXIF Tags
ok here is the redo. this is what i have so far. some work on the structure is yet needed.
Code:
/* metatagreadertwo0001.cpp */
#include <windows>
#include <fstream>
#include <iostream>
#include <string>
using namespace std;
int main() {
struct camm {
ExposureTime
FNumber
ExposureProgram
SpectralSensitivity
ISOSpeedRatings
OECF
ExifVersion
DateTimeOriginal
DateTimeDigitized
ComponentsConfiguration
CompressedBitsPerPixel
ShutterSpeedValue
ApertureValue
BrightnessValue
ExposureBiasValue
MaxApertureValue
SubjectDistance
MeteringMode
LightSource
Flash
FocalLength
SubjectArea
MakerNote
UserComment
SubsecTime
SubsecTimeOriginal
SubsecTimeDigitized
FlashpixVersion
ColorSpace
PixelXDimension
PixelYDimension
RelatedSoundFile
FlashEnergy
SpatialFrequencyResponse
FocalPlaneXResolution
FocalPlaneYResolution
FocalPlaneResolutionUnit
SubjectLocation
ExposureIndex
SensingMethod
FileSource
SceneType
CFAPattern
CustomRendered
ExposureMode
WhiteBalance
DigitalZoomRatio
FocalLengthIn35mmFilm
SceneCaptureType
GainControl
Contrast
Saturation
Sharpness
DeviceSettingDescription
SubjectDistanceRange
ImageUniqueID
}
int count;
string buff[256];
ifstream in( "CDSC000032.jpg" );
string s;
while(getline(in, s)) // Discards newline char
out << s << "\n"; // .... must add it back
}