用C编写的这个程序没有给出正确的输出

时间:2017-10-16 15:44:25

标签: c pointers codeblocks

这是一个将sting的字母转换为大写或小写的程序。我不知道这个代码有什么问题。当我运行它时,它省略了字符串的第一个字母。如果我给字符串,就像“让我们出去”,输出是 当转换为小写时,“ETS GO OUT”(“L”被排除,不应该发生)转换为大写,“ts out out”(“le”被排除,不应该发生)转换为小写。我使用代码块。请有人帮助我:'(

oldvars=`sed -n '/#### Variables configurables ####/,/#### Variables configurables ####/p' ACCBackup.sh`; sed -i "/#### Variables configurables ####/,/#### Variables configurables ####/c\$oldvars" temp_ACCBackup.sh 

1 个答案:

答案 0 :(得分:2)

您的func startRecording() { guard let firstDocumentDirectoryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true).first else { return } let directoryContents = try! FileManager.default.contentsOfDirectory(at: URL(fileURLWithPath: firstDocumentDirectoryPath), includingPropertiesForKeys: nil, options: []) print(directoryContents) videoURL = URL(fileURLWithPath: firstDocumentDirectoryPath.appending("/\(arc4random()).mp4")) print(videoURL.absoluteString) assetWriter = try! AVAssetWriter(url: videoURL, fileType: AVFileType.mp4) let compressionProperties:[String:Any] = [...] let videoSettings:[String:Any] = [...] let audioSettings:[String:Any] = [...] videoInput = AVAssetWriterInput(mediaType: .video, outputSettings: videoSettings) audioMicInput = AVAssetWriterInput(mediaType: .audio, outputSettings: audioSettings) audioAppInput = AVAssetWriterInput(mediaType: .audio, outputSettings: audioSettings) guard let assetWriter = assetWriter else { return } guard let videoInput = videoInput else { return } guard let audioAppInput = audioAppInput else { return } guard let audioMicInput = audioMicInput else { return } videoInput.mediaTimeScale = 60 videoInput.expectsMediaDataInRealTime = true audioMicInput.expectsMediaDataInRealTime = true audioAppInput.expectsMediaDataInRealTime = true if assetWriter.canAdd(videoInput) { assetWriter.add(videoInput) } if assetWriter.canAdd(audioAppInput) { assetWriter.add(audioAppInput) } if assetWriter.canAdd(audioMicInput) { assetWriter.add(audioMicInput) } assetWriter.movieTimeScale = 60 RPScreenRecorder.shared().startCapture(handler: recordingHandler(sampleBuffer:sampleBufferType:error:)) { (error:Error?) in if error != nil { print("RPScreenRecorder.shared().startCapture: \(error.debugDescription)") } else { print("start capture complete") } } } func recordingHandler (sampleBuffer:CMSampleBuffer, sampleBufferType:RPSampleBufferType, error:Error?){ if error != nil { print("recordingHandler: \(error.debugDescription)") } if CMSampleBufferDataIsReady(sampleBuffer) { guard let assetWriter = assetWriter else { return } guard let videoInput = videoInput else { return } guard let audioAppInput = audioAppInput else { return } guard let audioMicInput = audioMicInput else { return } if assetWriter.status == AVAssetWriterStatus.unknown { print("AVAssetWriterStatus.unknown") if !assetWriter.startWriting() { return } assetWriter.startSession(atSourceTime: CMSampleBufferGetPresentationTimeStamp(sampleBuffer)) } if assetWriter.status == AVAssetWriterStatus.failed { print("AVAssetWriterStatus.failed") print("assetWriter.error: \(assetWriter.error.debugDescription)") return } if sampleBufferType == RPSampleBufferType.video { if videoInput.isReadyForMoreMediaData { print("=appending video data") videoInput.append(sampleBuffer) } } if sampleBufferType == RPSampleBufferType.audioApp { if audioAppInput.isReadyForMoreMediaData { print("==appending app audio data") audioAppInput.append(sampleBuffer) } } if sampleBufferType == RPSampleBufferType.audioMic { if audioMicInput.isReadyForMoreMediaData { print("===appending mic audio data") audioMicInput.append(sampleBuffer) } } } } func stopRecording() { RPScreenRecorder.shared().stopCapture { (error) in guard let assetWriter = self.assetWriter else { return } guard let videoInput = self.videoInput else { return } guard let audioAppInput = self.audioAppInput else { return } guard let audioMicInput = self.audioMicInput else { return } if error != nil { print("recordingHandler: \(error.debugDescription)") } else { videoInput.markAsFinished() audioMicInput.markAsFinished() audioAppInput.markAsFinished() assetWriter.finishWriting(completionHandler: { print(self.videoURL) self.saveToCameraRoll(URL: self.videoURL) }) } } } 循环等效于以下代码:

while

因此,要解决此问题,您可以使用while (*p) { *p = tolower( *(p+1) ); p = p+1; } 循环,例如:

for